Git Product home page Git Product logo

verless / verless Goto Github PK

View Code? Open in Web Editor NEW
309.0 4.0 29.0 1.45 MB

A Static Site Generator designed for Markdown-based content with a focus on simplicity and performance.

License: Apache License 2.0

Go 87.78% Python 6.29% Dockerfile 2.07% CSS 0.12% HTML 3.02% Makefile 0.64% SCSS 0.08%
static-site-generator blog-engine blog content-management-system markdown static-site hacktoberfest

verless's Introduction







A simple and lightweight Static Site Generator.





verless (pronounced like serverless) is a Static Site Generator designed for Markdown-based content with a focus on simplicity and performance. It reads your Markdown files, applies your HTML templates and renders them as a website.

Features

  • Flexible theming: Themes define the HTML templates as well as styles and scripts for your frontend. Initializing a new theme can be done within a single command, and setting it as active requires a single line of configuration. Since verless provides pre-defined template variables, themes are interchangeable.

  • Rapid development: Just like themes, new projects can be created using a single command. Local development requires no third-party webserver as verless comes with a built-in webserver and rebuilds your project when something changes.

  • High performance: Generating a static site typically is a matter of milliseconds. To keep build times short, verless lets you choose and explicitly enable features you need - only generate RSS feeds or overview pages for tags if you want to.

  • Focus on simplicity: Global information, page types, plugins and other settings are configured in a central configuration file inside your project. We try to keep things small and simple, and if your project isn't simple, verless probably isn't a good fit.

Examples

Installation

Linux and macOS

Download the latest release for your platform. Extract the downloaded binary into a directory like /usr/local/bin. Make sure the directory is in PATH.

Windows

Download the latest release, create a directory like C:\Program Files\verless and extract the executable into that directory. Add the directory to Path.

Docker

Assuming your project directory is my-blog, the following command builds your website:

$ docker container run -v $(pwd)/my-blog:/project verless/verless

The container will build the project mounted at /project and you'll find the website in my-blog/target. To run another command, just append it to the image name:

$ docker container run verless/verless version

Getting started

The easiest way to create a new project is to use the verless CLI:

$ verless create project my-blog

This initializes a project called my-blog inside a new directory, containing a small default site. You can either build the project or serve the static site directly:

$ verless serve -w my-blog

After running the command, you can view your new project under localhost:8080. Building the project works similary and generates a deployable website:

$ verless build my-blog

By default, verless generates the website into my-blog/target. You are now ready to create your first blog post!

Documentation

To find out how a verless project is structured, take a look at the example project. For a detailed reference, check out the documentation.

๐Ÿ”ฅ New tutorial: Create a website using verless

Contributing

Anyone is welcome to contribute to verless. Please refer to our contribution guidelines.


verless's People

Contributors

aligator avatar ananichev avatar archern9 avatar coconutlad avatar codenoid avatar danih0311 avatar dependabot[bot] avatar dominikbraun avatar felixmohr avatar gabrielfalcom avatar hmble avatar ivanruvalcaba avatar mo3taz1705 avatar pankhudib avatar rachit-iam avatar rperry99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

verless's Issues

Introduce verless create command

We need a verless create command to initialize a new verless project. The project name should be a command argument, so that a new project can be created like so:

$ verless create my-blog

The command should create the my-blog directory, an empty verless.yml file as well as the content, assets and templates directories.

Provide route information to each page

At the moment, there's a Page field available in index pages, containing Page instances. Those instances only hold the page ID, but not the route to that page - since the route is stored as a map key internally, and the page is a value for that key.

There needs to be a way to access the route from a template. Maybe by storing the route in the page, even though this means a little redundancy.

Create documentation

There should be a user documentation that contains

  • a configuration reference
  • a template reference
  • a plugin reference and
  • a command reference.

Make tags plugin register pages in site model

Since #52, build.Plugin offers the possibility to register a page in the site model before it is written by the build.Writer. At the moment, the tags plugin writes the files itself, but once #52 is merged, it should register its pages in the site model without rendering anything itself.

Improve plugin loading

At the moment, HasPluginKey iterates over all plugins and checks if there is a plugin with a given key. This function is called for each known plugin key manually.

It would be more flexible and alot more efficient to read the given plugin keys, see if they're in a map and load the plugin from the map with the respective key.

Support generic data in templates

There should be a possibility to provide custom data as YAML, TOML or JSON files and access them in templates, or render static pages based on that data respectively. This probably will be a new plugin.

Re-think plugins API

The interface methods of build.Plugin should be re-considered.

  • At the moment, the tags plugin needs the generated model.Site, because it needs to render index pages for each tag with the site's navigation. It would be more elegant to hook into the site model and let the writer write the tag index pages, just as the other index pages.

Introduce version key for verless.yml

The configuration (config.Config for verless.yml) needs a new top-level string key: version. At this time, the key can be ignored in the other parts of the application.

Unify flag descriptions

The CLI flag descriptions should be unified. The current output looks as follows:

...
Flags:
  -h, --help            help for build
  -o, --output string   Specify an output directory.
      --overwrite       Allows overwriting an existing output directory.

The auto-generated help texts like help for build differ from our own texts: Specify an output directory.. It would be nice if the could lowercase the help texts and remove the trailing dots, e. g. specify an output directory.

Simplify concurrent build error handling

At the moment, the concurrent build error handling seems to work as intended, but is far from simple. There are some aspects to consider:

  • Do all errors have to be returned?
  • Should the workers be shut down gracefully?
  • Can the channel system be simplified?

Personally, I'd say no - yes - yes. I think only handling a single error and shutting down gracefully would drastically simplify the error handling process.

Make Page fields private

There are some fields in model.Page which should not be accessed from templates, like RelatedFQNs or Hide.

RelatedFQNs []string

These exported fields should be made private. To be able to get and set them internally from other packages, there need to be getter and setter methods for them, and those should be accessed instead.

Enable plugins in verless.yml

Instead of introducing a flag for each plugin, like --enable-atom, the plugins enabled for a project should be defined in verless.yml. The best choice would be a plugins: key with a list of plugins.

Implement tag plugin

Since verless supports page tags, there also has to be a respective plugin for processing the tags.

The tags plugin should

  • collect all pages that have a certain tag (store references to the pages)
  • write a directory in the output path called tags, which contains a directory and the articles for each tag.

Introduce Type field for Markdown content

In addition to providing a custom template using Template: my-template.html, there should be a Type: my-type field that loads my-type.html from the template directory. It should be the preferred way of using different templates than page.html.

Change verless build command

Currently, verless build builds the current directory. To build a different directory, the path has to be specified with -p: verless -p example build.

This should be changed: The build path needs to be an argument for verless build, so that the current directory can be built using verless build . and a different directory using verless build example.

This is also consistent with the planned create command.

Introduce route package

The business logic related to filepaths and routes should be summarzied in a central route package. For example, instead of manually checking a path ...

if !strings.HasPrefix(path, "/") {
    // error
}

... the route package should be responsible for maintaining that business logic.

if !route.IsValid(path) {
    // error
}

To avoid confusion at this point, model.Route should be renamed to Node (#86).

Introduce content types

This will supersede #58.

Content types should be configurable in the verless.yml file with an own types key:

types:
    blog-post:
        template: post.html

The only content type property at this time is template. The may infer the template file in case it isn't configured explicitly at a later time, but for this first implementation, the template key should be mandatory.

Just like in the original issue #58, the YAML key in the Markdown Front Matter should be Type.

Add serve command

The serve command first builds the project and then opens a webserver which serves the result.

verless serve path/to/project

A bonus if easy possible: option --watch which automatically rebuilds the project if any file in it changed.

Image generation plugin

verless sooner or later needs a plugin for generating smaller versions of images.

To be discussed internally

Build generates child directories in root route

Structure:

content/
    blog/
        coffee/
            making-barista-quality-espresso.md

Expected output:

target/
    blog/
        coffee/
            making-barista-quality-espresso/
                index.html

Actual output:

target/
    blog/
    coffee/
        making-barista-quality-espresso/
            index.html

wrong output folder

using go run ./cmd/main.go build -p in -o out
it reads the folder in and outputs the folder in/out
I would expect that it is reading from in and writing to out

The funny thing about it:
The rss-plugin already does it like that, which leads to an error because out doesn't exist.

Create template package

At the moment, the writer component and the tags plugin use the same template, and they have to compile it for themselves, so the same template has to be compiled multiple times.

To avoid this, there should be a global template (or tpl) package that provides a template factory function which

  • compiles a template if it doesn't exist
  • caches the compiled template
  • returns the template from the cache.

Remove .pid file from releases

At the moment, CircleCI's /tmp directory seems to contain a .pid file, which is released to GitHub along with the archives. This file shall be removed from the releases. Preferrably by moving the artifacts for releases in an own directory.

Improve error for failing go-check CI job

If the go-check CI job/one of its steps fails, the current error message isn't too helpful:

Exited with code exit status 1
CircleCI received exit code 1

There should be a clear error message for each step.

Feedback: Praise and Criticism

This issue is a collection of constructive feedback, especially from a technical perspective.

  • What do you enjoy about verless and its development?
  • What could be done better?
  • What would you like to change?

Local test are failing

My local tests fail:

Test Output
GOROOT=C:\Go #gosetup
GOPATH=C:\Users\domin\go #gosetup
C:\Go\bin\go.exe test -json ./... #gosetup
=== RUN   TestBuilder_RegisterPage
--- PASS: TestBuilder_RegisterPage (0.00s)
=== RUN   TestBuilder_Dispatch
--- PASS: TestBuilder_Dispatch (0.00s)
PASS
ok  	github.com/verless/verless/builder	(cached)
=== RUN   TestMarkdown_ParsePage
--- PASS: TestMarkdown_ParsePage (0.00s)
PASS
ok  	github.com/verless/verless/parser	(cached)
=== RUN   TestSite_CreateRoute
--- PASS: TestSite_CreateRoute (0.00s)
=== RUN   TestSite_ResolveRoute
--- PASS: TestSite_ResolveRoute (0.00s)
=== RUN   TestSite_WalkRoutes
--- PASS: TestSite_WalkRoutes (0.00s)
PASS
ok  	github.com/verless/verless/model	(cached)
=== RUN   TestAtom_ProcessPage
--- PASS: TestAtom_ProcessPage (0.00s)
PASS
ok  	github.com/verless/verless/plugin/atom	(cached)
?   	github.com/verless/verless/cli	[no test files]
?   	github.com/verless/verless/cmd	[no test files]
?   	github.com/verless/verless/config	[no test files]
?   	github.com/verless/verless/core	[no test files]
?   	github.com/verless/verless/core/build	[no test files]
?   	github.com/verless/verless/fs	[no test files]
?   	github.com/verless/verless/test	[no test files]
=== RUN   TestWriter_removeOutDirIfPermitted
    writer_test.go:77: Testing 'already exists but without file'
writer_test.go:50: unexpected error: mkdir ../test-out-path: Eine Datei kann nicht erstellt werden, wenn sie bereits vorhanden ist.

    test.go:35: mkdir ../test-out-path: Eine Datei kann nicht erstellt werden, wenn sie bereits vorhanden ist.
writer_test.go:86: unexpected error: the output folder already exists and is not empty
condisder using the --overwrite flag

    test.go:35: the output folder already exists and is not empty
        condisder using the --overwrite flag
    writer_test.go:77: Testing 'already exists with overwrite'
writer_test.go:66: unexpected error: remove ../test-out-path\anyFile.txt: Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird.

    test.go:35: remove ../test-out-path\anyFile.txt: Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird.
    writer_test.go:77: Testing 'not exists with overwrite'
    writer_test.go:77: Testing 'normal'
writer_test.go:86: unexpected error: the output folder already exists and is not empty
condisder using the --overwrite flag

    test.go:35: the output folder already exists and is not empty
        condisder using the --overwrite flag
    writer_test.go:77: Testing 'already exists'
writer_test.go:36: unexpected error: mkdir ../test-out-path: Eine Datei kann nicht erstellt werden, wenn sie bereits vorhanden ist.

    test.go:35: mkdir ../test-out-path: Eine Datei kann nicht erstellt werden, wenn sie bereits vorhanden ist.
writer_test.go:43: unexpected error: remove ../test-out-path\anyFile.txt: Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird.

    test.go:35: remove ../test-out-path\anyFile.txt: Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird.
--- FAIL: TestWriter_removeOutDirIfPermitted (0.01s)
FAIL
FAIL	github.com/verless/verless/writer	0.273s

Process finished with exit code 1

This has been introduced with fb3e2a1.

Unit tests for build

The tests should cover if the actual build works. It may be useful to run this tests on a example project included in this repository.

Provide example project

There should be an example project in the verless repository for 3 purposes:

  • Providing a quick example for potential users
  • Providing a test project to build for developers
  • Maybe providing a test project for unit testing

Use relative links in Markdown files

All Markdown files should use relative links instead of absolute ones.


Just a question: would it be possible and make sense to use relative paths? Is there any best practice?
Then the links would also work without github...

Originally posted by @aligator in #85 (comment)

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.