Pages

Wednesday, 23 October 2024

zine, 基于ruby的静态博客程序


Gem Version

Zine is an open source, command line, blog-aware, static website generator.

Distinguishing features include:

  • ERB templates
  • Sass stylesheets
  • fast incremental builds
  • a choice of AWS S3, GitHub & SFTP file uploaders

How do I get it?

Zine is a Ruby Gem, so if you have Ruby on your machine (it comes installed standard on a Mac), open Terminal & type

gem install zine

And you're away.

To generate a new scaffold site, cd to a new directory and:

$ zine site

Then update your site's name, your name & so on in zine.yaml. Pay particular care to the Upload section, if you want to use Zine to deploy files you've changed, you'll need to edit this section to include your remote server's details, including the path to a YAML file with your credentials.

Day to day use

To set up a new blog post:

$ zine post 'Your chosen title'

Your new post will have some fields set up in the YAML front matter, feel free to edit them too.

You can also create other Markdown files outside of the posts folder, those will be rendered into HTML in the same relative position in the build folder. That's how the project, about etc pages on my site are made for example.

Type zine build before you start writing to serve up a local copy of your site that you can refresh to see what the build version will look like.

$ zine build

or

$ zine force

Build will only watch for the things that change while it's running, so the first time you build your site you should use force -- force writes all of the files (& so also uploads them all too if you've set up uploads).

Control-C in Terminal when you're done.

Design & development

Typing zine style will render the Sass file into CSS. The templates are all editable, as are the files' names, which you can change in the options file.

Halp!

To see the options available type zine & hit enter:

$ zine
Commands:
  zine build           # Build the site
  zine force           # Build the site, forcing writes & uploads
  zine help [COMMAND]  # Describe available commands or one specific command
  zine notice POST     # Build the site, then force the one POST
  zine nuke            # Delete the build folder
  zine post TITLE      # Create the file for a new blog post, titled TITLE
  zine site            # Create the skeleton of a new site (overwriting files)
  zine style           # Build the site's stylesheet
  zine version         # Show the version number
  • Code - show me the code
  • Ruby gems - show me the Ruby details (pick up some gems while you're there)
from https://codeberg.org/kreuzer/zine
(https://github.com/zineland/zine)
-------------------------------
 
MiniJinja is a powerful but minimal dependency template engine for Rust compatible with Jinja/Jinja2  .
 

MiniJinja: a powerful template engine for Rust with minimal dependencies

Build Status License Crates.io rustc 1.63.0 Documentation

MiniJinja is a powerful but minimal dependency template engine for Rust which is based on the syntax and behavior of the Jinja2 template engine for Python.

It's implemented on top of serde and only has it as a single required dependency. It supports a range of features from Jinja2 including inheritance, filters and more. The goal is that it should be possible to use some templates in Rust programs without the fear of pulling in complex dependencies for a small problem. Additionally it tries not to re-invent something but stay in line with prior art to leverage an already existing ecosystem of editor integrations.

$ cargo tree
minimal v0.1.0 (examples/minimal)
└── minijinja v2.4.0 (minijinja)
    └── serde v1.0.144

Additionally minijinja is also available as an (optionally pre-compiled) command line executable called minijinja-cli:

$ curl -sSfL https://github.com/mitsuhiko/minijinja/releases/latest/download/minijinja-cli-installer.sh | sh
$ echo "Hello {{ name }}" | minijinja-cli - -Dname=World
Hello World

You can play with MiniJinja online in the browser playground powered by a WASM build of MiniJinja.

Goals:

Example

Example Template:

{% extends "layout.html" %}
{% block body %}
  <p>Hello {{ name }}!</p>
{% endblock %}

Use Cases and Users

Here are some interesting Open Source users and use cases of MiniJinja. The examples link directly to where the engine is used so you can see how it's utilized:

Getting Help

If you are stuck with MiniJinja, have suggestions or need help, you can use the GitHub Discussions.

Related Crates

Similar Projects

These are related template engines for Rust:

  • Askama: Jinja inspired, type-safe, requires template precompilation. Has significant divergence from Jinja syntax in parts.
  • Rinja: Jinja inspired, type-safe, requires template precompilation. Has significant divergence from Jinja syntax in parts.
  • Tera: Jinja inspired, dynamic, has divergences from Jinja.
  • TinyTemplate: minimal footprint template engine with syntax that takes lose inspiration from Jinja and handlebars.
  • Liquid: an implementation of Liquid templates for Rust. Liquid was inspired by Django from which Jinja took it's inspiration.

from https://github.com/mitsuhiko/minijinja 

(cd ~

git clone https://github.com/mitsuhiko/minijinja

cd minijinja

cargo build --release

在生成的target/release目录里,出现了 minijinja-cli.exe

~/minijinja/target/release/minijinja-cli.exe -h )

 

 

No comments:

Post a Comment