Coder Social home page Coder Social logo

static-site-generator's Introduction

Java Static Site Generator (JSSG)

Maven Central

A simple Static Site Generator (SSG) for generating a complete HTML website from raw data and files, without having to author any HTML by hand.

Built with

Getting Started

Prerequisites

Installation

<dependency>
  <groupId>io.github.trangntt-016</groupId>
  <artifactId>jssg</artifactId>
  <version>1.0.0</version>
  <type>jarhttps:</type>
</dependency>

Change the arguments with the following options

Options
Usage
--h, --help Display a list of options
--v, --version Display current version of jssg
--i, --input Allow the user to specify an input file or folder to be processed. It will generates one .html output file for each input file and the filename is based on the title of the story’s header
--o, --output Specify a different output path (default is ./dist)
--l, --lang Indicate the language to use when generating the lang attribute on the root element
--c, --config Indicate the path to a JSON config file

Executing program

  • clone this github

git clone https://github.com/trangntt-016/static-site-generator.git

  • Install jssg
cd ./static-site-generator

Config the .bat file

Right click on jssg.bat -> edit -> change D:\SchoolWork\OSD600\static-site-generator\target\jssg-0.0.1-SNAPSHOT.jar to your absolute path where the jssg-0.0.1-SNAPSHOT.jar locates 
Save

Config the system environment

Start -> Edit system environment variables -> Environment variables -> User variables: Path -> New -> (Absolute path where your jssg.bat file locates)-> ok

Then, look at the 2nd block: system variables: Path -> New -> (Absolute path where your jssg.bat file locates)-> ok

Ok -> Apply -> Ok
  • Run jssg Open Windows Terminal -> jssg -h

Features

  • Display the version of the tool and a list of command lines by using (--h, --v, --help, --v)

  • Allow the user to specify an input file or folder to be processed, using --input or -i . Then it generates one .html output file for each input file and the filename is based on the title of the story’s header. For example: jssg -i '.\src\main\resources\Sherlock Holmes Selected Stories'

  • jssg places all output into a ./dist folder by default. Each time the tool is run, an existing dist folder should first be removed so that dist always contains the last output.

  • If --output or -o werent’s specified, dist will be used. If the user specifies a different output path (--output or -o), jssg will use that, it also prints an error if the specified output path is not a valid directory.

  • If the user specifies a folder for the input, Jssg automatically generates an index.html file, which has relative links to each of the generated HTML files.

  • Add an optional -l, --lang, which indicates the language to use when generating the lang attribute on the root element. For example, --lang fr would mean that the HTML documents are in French, and would include , while -l pt-BR would mean the text is using Brazilian Portuguese: . By default, use en-CA for Canadian English.

  • Add support for inline <code> blocks. In Markdown, enclosing text in a single backtick causes the text to HTML to get rendered as <code>...text...</code>.

  • Add an optional -c, --config which indicates the path to a JSON config file. For example: jssg -c '.\src\main\resources\Sherlock Holmes Selected Stories'

    // ssg-config.json
    {
      "input": ".\\src\\main\\resources\\Sherlock Holmes Selected Stories\\",
      "output": "./build",
      "randomKey": "nullptr",
      "missing-lang": "fr-CA",
    }

Demo

Output: https://trangntt-016.github.io/static-site-generator/

Features:

  • Display version of the tool:

  • Automatically generate various HTML files from .txt files based on the argument

License

This project is licensed under the [MIT] License - see the LICENSE.md file for details

Author

Trang Nguyen (Tracy)

Acknowledgment

static-site-generator's People

Contributors

andrewnt219 avatar trangntt-016 avatar

Stargazers

 avatar

Watchers

 avatar

static-site-generator's Issues

Text processing

The file is reading line by line and then transfer to the paragraphs by parsing it into StringBuilder first. Suggestion: for the later development, could it be more precise?

Add an optional -l, --lang, and/or \l flag, which indicates the language to use

Add an optional -l, --lang, and/or \l flag, which indicates the language to use when generating the lang attribute on the root element. For example, --lang fr would mean that the HTML documents are in French, and would include , while -l pt-BR would mean the text is using Brazilian Portuguese: . By default, use en-CA for Canadian English.

Add support for config.json

Describe the feature

Hi @trangntt-016, I want to add support for reading in a config.json as an alternative to CLI arguments (e.g. --input, --lang,...).

ssg --config ./ssg-config.json
{
  "input": "./docs",
  "output": "./web",
  "future-feature": "should be ignored for now"
}

Describe the solution

For supporting --config, I'll add another @CommandLine.Option. If the --config flag is used, ignore other flags.

I'm going to init the value of JssgApplication with pairs from the JSON file. That way, all the logic for parsing the file can be the same. To parse the JSON config, I'll have to add org.json or GSON as a dependency.

Create a page for docs (md files)

This feature displays a list of documentation for .md files

  • Any -i for .md will be placed in ./docs 
  • index.html will render a new link Pages (which includes the generated stories from text files and Docs (which includes the generated documents from .md files)

Approach:

  • Modify the current index.html to have another link to the docs
  • Create a new path ./docs to store .md files

Full markdown support

This feature helps to compose the interactive documentations with ease

  • .md will be converted to .html with full features (< h1 >, < ul > , < li >,< strong >, < em > , etc.)
  • Syntax Highlighting for code blocks

Approaches:

  • Install Java library (txtMakr) to convert .md to .html
  • Write function to read the code block (some codes) and convert them to some codes
  • Refactor current codes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.