npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

thymol-node-server

v1.0.0-pre.8

Published

A nodejs based server-side JavaScript Thymeleaf template engine built on Thymol and Express

Downloads

11

Readme

Thymol Node Server

A nodejs based server-side JavaScript Thymeleaf template engine built on Thymol and Express.

This is an experimental web server that processes server-side Thymeleaf templates, JavaScript and data using Thymol and returns documents rendered as HTML.

Pre-Requisites

You will need nodejs and npm (node comes with npm now). This project depends on the Thymol Node module see npmjs and github.

Installation

Either "npm install thymol-node-server -g"

Or clone the project from github and "npm install" it (locally).

Execution

If you globally installed with npm all you need to do is:

thymol [-w <path-to-webapp-script>] [-c <path-to-config-file>] <path-to-webapp-root> [<relative-path-to-templates>]

If you're using a git clone:

Then on *nix simply run:

 bin/thymol-server [-w <path-to-webapp-script>] [-c <path-to-config-file>] <path-to-webapp-root> [<relative-path-to-templates>]

On Windows run this file using the nodejs node command:

node bin/thymol-server [-w <path-to-webapp-script>] [-c <path-to-config-file>] <path-to-webapp-root> [<relative-path-to-templates>]

Where:

"<path-to-webapp-script>" is the (optional) path locating the script that loads and intialises the web application code.

"<path-to-config-file>" is the (optional) path locating the configuration file (see below).

"<path-to-webapp-root>" identifies the base directory of your web application (the webapp root directory).

"[<relative-path-to-templates>]" is the (optional) relative path from the webapp root directory to the template directory.

References to resource files should be relative to the webapp root directory.

Configuration

Thymol Node Server is configured using a simple JavaScript file. The default configuration file is loaded from "config/server-config.js".

You can edit this file or nominate an alternative using the "-c " option on the server start-up command line.

You can use the configuration file to set the values of Thymol control parameters (see). The configuration file can also be used to set web server control parameters (server host name, port etc).

For example, the values for webapp root and template path can be specified in the configuration file so that they don't have to be specified on the command line.

There are two control parameters specific to Thymol Node Server:

dataThymolLoading: this is a boolean control, if set to "true", the server will load and execute any JavaScript files that are specified in "data-thymol-load" attributes of <script> tags in templates as they are processed.
                   The value of this control defaults to "false", so "data-thymol-load" scripts are ignored by default.
 
resetPerRequest: this is a boolean control, if set to "true", the server will reset all internal configuration on receipt of every new request. (This is used by Thymol automated integration tests). 

You can also use the configuration file to "fine tune" the jQuery configuration using the jQueryConfiguration initialiser (properties of this object are set on jQuery instances).

For example using:

jQueryConfiguration: {
  support: {
    cors: true
  }
}

Will set the "support.cors" property of jQuery instances to "true" (you may need to do this if you're using jQuery 1.x.x).

Operation

The thymol-server will process templates rooted at the specified webapp-root value.

The server follows the same syntax and applies the same rules as client-side Thymol except that JavaScript files defined by the "src" attributes of <script> tags are ignored.

JavaScript files defined by "data-thymol-load" attributes in <script> tags will also be ignored unless the "dataThymolLoading" configuration option is set to "true".

Examples

The following 2 examples illustrate some familiar static demonstration cases.

a). Download the 2.X-master branch from thymol.js and start the server with the sourceforge/Webcontent sub-directory as the webapp root directory:

thymol <installation-path>/thymol/sourceforge/Webcontent

Then browse to http://localhost:3000/examples. Most of these examples should work correctly with the exception of "say hello (split)" and "session" that depend on client-side only features.

b). Clone the Thymol petclinic example project and start the server with "petclinic.js" as the web application code file, the src/main/webapp sub-directory as the webapp root directory and "/WEB-INF/thymeleaf" as the template path:

thymol -w <installation-path>/src/main/webapp/resources/thymol/petclinic.js  <installation-path>/src/main/webapp /WEB-INF/thymeleaf

Where <installation-path> is the fully qualified path to the project installation directory (including "thymol.thymeleafexamples-petclinic").

Once the server has started, browse to http://localhost:3000/welcome - you should see the well known petclinic home page.

Most of the remaining petclinic site pages will not work correctly until the back-end database has been set up correctly. For instructions on how this is done please see here.

Issues/Support

For bug reports/enhancement requests use the issues link here.

For support or further information, please post a question on the Thymol users forum.