Clojure website to html and javascript? - web

The question is: is there a way to get or compile a website written in clojure to HTML and Javascript files without having .WAR file for the server? Thank you.

For that you may want to look into writing the site in ClojureScript. It's a different language though very similar to Clojure. This would make it possible to write the entire site using client side java script and static resources like HTML, CSS, Images, etc. Or you could use node to run the generated server side JavaScript.
Another option, depending on how I interpret your question would be to write it as a dynamic site in Clojure, then spider the whole thing using wget and save a static snapshot of it. Though perhaps that's not what you where asking for? You could also use Hickup or Enlive to create templates and then run the templates to produce html that you serve statically with no app server or dynamic content.

If you want to create a static site, there are couple of options,
https://github.com/nakkaya/static
https://github.com/liquidz/misaki

Related

Live Server for Static Markdown Websites

I am currently looking into static site generators.
I build a testing documentation site with Vuepress and am now fiddling with going into the live operation.
i don't want to publish my files to services (GitHub Pages, Netlify etc.) but I want to host it on my own server.
Generating static html sites everytime I add markdown pages or change the content is not an option.
Is there a way to host Vuepress (or maybe similar markdown generators) where I just need to upload the .md files and everything goes automatically?
There are two basic ways to use markdown as your website...
use a live server:
In this scenario, each request is processed by a program which retrieves the markdown text and does some pre or post processing (templateengine, formatting etc).
This could be a simple CGI script, a web framework or a custom server.
use a static site generator:
You process the markdown on your lokal machine and generate static html files, which are uploaded and served by a web server.
To answer your question whether or how you can use vuepress:
There are multiple possible ways, depending on your current setup.
If you only have some webspace, than you have to upload prerendered html files (or using another framework).
If you have a virtual server, than you can automate the build/rending process by using scripts, e. g. with file watchers.
Note to GitHub:
Even if you said, that you don't want to use GH... If you only want to hide the markdown files, you can create a private repository and use GH Actions as CI/CD pipeline.
Unfortunately Stackoverflow is not for software recommendation, so for alternatives to vuepress have a lookt at Software Recommendations.

MEAN stack - reliance on templating (Angular vs Templating Engines)?

This may come from a lack of experience on the various sections of the MEAN stack, but from the various boilerplates I've seen (mean.io, hackathon-starter, etc.) in the app.js code, there is always a call to using jade templating engine. I know that I can switch this to ejs and the like, but I was wondering if there's a means of doing it to where all of my pages are .html files using AngularJS? The components/templating features I'm interested appear to be in Angular already so I'm not sure what I'm losing if I were to attempt to server .html files instead?
If you have multiple html pages in your application, template engine can reduce code duplication between them.
Also, you usually need server-side template engine to provide some kind of a fallback to users who don't have javascript turned on (+ search engines).
I prefer jade over other template engines (and plain html), precisely because it's not html. So it doesn't have certain html issues like whitespace nodes, and always compiles into well-formed html file.
If you follow meanjs.org it uses swig, which parses as HTML. You may consider doing the same?

AngularJS with Express Templates or pure HTML? Pros and Cons?

Express JS uses templates for generating HTML and then server sends them to client in response. There may be several other templates from which HTML can be generated. The ones I was able to discover are:
Jade (http://jade-lang.com/)
EJS (http://embeddedjs.com/)
In my app, I need to use both ExpressJS and AngularJs. I am new to both technologies. While learning angular, I had to use it in pure HTML. After learning ExpressJs, I realized, in order to use angularjs, I need to use them in any of the above templates which will be converted to HTML while sending to client.
Now, I want to use expressjs as my server and angularjs as my client side app. For this, I think I have two options.
Option 1
I can stop using templates altogether and use our NodeJS server to respond by sending simple HTML files. These HTML files will then contain AngularJS coding within them. AngularJS then, on client side, will act as our application. It will demand other HTML documents from the server. Or it can also be used like AJAX, where we can only request the piece of information to update just part of the page rather refreshing the whole page for a minor change.
Option 2
I can use angularjs inside expressjs templates (jade or ejs).
Kindly, help me in understanding the pros and cons of both options. Which one will be your choice in such case.
This is very much an opinion question and Stack Overflow admins hate anything that smacks of opinion, but here's my experience and opinion nevertheless.
I've done a couple of apps now using purely static files (HTML, CSS, and JavaScript) with those calling a service on the back-end to deliver the data. It reduces the back-end, whatever it is (I've used both Java and Node.js), to just being a set of service URLs but it works very very well.
You've got a fantastic hard line between the responsibilities of the
two systems
It's very easy to work on and test each one independently
Bugs are usually very clearly in the front-end or the back-end (all
you have to do is look at the data transferred to know)
The back-end services are ready to be reused to support alternative UIs from the
command line or something mobile specific if you want
You can use one technology for the back-end to start with (say Node.js or Ruby on Rails) and then switch to something else later if you need to. As long as the API stays the same the front-end never knows.
I personally use AngularJS with Express/Jade. The setup is actually pretty simple and I find writing Jade much more enjoyable than writing HTML. I've also adopted writing my Angular code in CoffeeScript as, again, it makes for quicker development. If you are looking to save keystrokes then Jade is a great solution and its integration with Express makes it a no brainer. If you aren't worried about producing code more quickly then there is absolutely no problem with using HTML.
I will point out that one of the greatest benefits I have found to using Jade over HTML is the ability to develop a single page in multiple files, then use include to have them concated before compiling into HTML. This allows you to take larger pages and break them into more manageable chunks. Together with Angular's templating, this can relieve much frustration.
Really it is all a matter of opinion, but since I decided to give Jade a shot, I have not regretted it and I have never ran into a situation where my HTML was rendered incorrectly when using Angular.
I went with option 1 because I didn't want to deal with any potential issues with jade or ejs converting the template incorrectly and interfering with Angular. My app essentially has the index page (which is really just the basic page template with my css and js includes) come out of Express as jade and then angular takes it come there and all my angular templates are in a separate location than my jade template.

CoffeeScript, Node.js, MongoDB and JasperReports, is it possible?

I just realized a JSF (web JavaScript application) that connect to a MongoDB database and generate a report (PDF) thanks to JasperReports Library (so with a .java file).
Is it possible to do the same thing with a web application in CoffeeScript and Node.js? I am really new to this, so I don't know where to start.
For example: Is it possible to run a .java thanks to Node.js or CoffeeScript?
JSF is actually a JavaServer Faces application, not a JavaScript application. JavaScript (which Node.js, CoffeeScript are based on) is not equivalent to Java despite the similarity in names.
If you already have a JSF-based application then you already should have everything you need to create a web-based application. There is no need for Node.js, CoffeeScript, etc.
Go take a look at JSP, Tomcat, etc. to figure out how to render web pages rather than output to PDF and you should be set.
If you want to rewrite your application in javascript and run it on node.js, you should be able to use PDFKit to build the PDFs.
If you only wish to use your existing application and integrate it with a node.js server, I think you would be wise to run them in parallel (or proxy requests to your JSF application through node, in case that makes sense). It's hard to give a better answer unless you can state more clearly what it is you want to accomplish.
Yes, it's possible. You can start / stop / control another process with Node.js - so You can start .java in another process and use it to generate PDF. But ... it may be not very efficient in terms of resource usage, so it's an open question.
Or, you can write a simple worker that will generate PDF from JSON data and use 0MQ or other inter-process communications between Node.js and this Java worker.
He-he, JSF was one of the worst technologies I ever saw (I believe it's still in the same state now as it was in 2007 when I left Java), even dumb JSP and servlets was better...

How do you include a JavaScript file from within a SharePoint WebPart?

We have a medium sized .js file that we include in our web framework that I am porting over to SharePoint. However, I'm not sure how to go about this or what the best practice is. This is for a framework solution that will be used by other client projects, so it's best for it to be self contained and deploy-able, rather than requiring manually deploying files to the webserver.
My current thinking to put the JavaScript into an embedded resource and then use the script manager to write out the file. Does this seem reasonable? Or does anyone have any other recommendations?
Embeded resource is the best way and you don't need to use the ScriptManager to render it out (as AJAX is not configured OoB on SharePoint), you can just render it as any other client script resource (through the ClientScriptManager).
Best idea is the have an if ContainsScriptManager else UsClientScriptManager style.
That way you get the best of both worlds
You could just toss it into a doc library.
If you are packaging your web part into a sharepoint solution, you could include it as a Module (VSEWSS item). Your manifest file would get something like:
<TemplateFiles>
<TemplateFile Location="LAYOUTS\somescript.js" />
</TemplateFiles>
Theres lots of info on how to do this on the web. I've liked the doc library option for images, css, and javascript because I don't have to rebuild and wait for for SP to JIT compile for 30 seconds each time I do a minor tweak to some style or script. I just edit these things in SPDesigner right out of the doc library.
Create resource mapped folder in your project and put the js file there and give the referene of the js file as _layout/jsfilename.js and this js file will be deployed with your project where ever you will deploy it.

Resources