LoginSignup
5
5

More than 5 years have passed since last update.

Lektor 静的サイトジェネレータ

Last updated at Posted at 2016-04-03

Jinja2Flaskの作者、mitsuhikoさんが Lektorという、静的サイトジェネレータを少し前に公開していたので、少し調べてみました。

トップページのチャッチセールスは

A flexible and powerful static content management system for building complex and beautiful websites out of flat files — for people who do not want to make a compromise between a CMS and a static blog engine.

Getting your ideas implemented is as easy as making breakfast eggs.

CMSかブログエンジンの間で妥協したくない人のための、フラットファイルから複雑で、美しいWebサイトを作るための、柔軟で強力な静的コンテンツマネージメントシステム

朝食の卵料理を作るぐらい簡単に、アイデアを形にできます

Moongiftさんでも以前紹介されていたようですが、開発がだいぶ進んでいるよう、見た目が良くなってます。

残念ながらpython3にはまだ対応していないようで(  2.0で対応する予定らしい。 2.0には間に合わなかったようで、3.0になるみたいです。(2016-04-16))利用するにはPython2が必要です。

インストール自体はとても簡単で、シェルスクリプトを走らせるか、pipでインストールします。

インストールが完了したので、コマンドでヘルプを確認すると。

#lektor --help


Usage: lektor [OPTIONS] COMMAND [ARGS]...

  The lektor management application.

  This command can invoke lektor locally and serve up the website.  It's
  intended for local development of websites.

Options:
  --project PATH   The path to the lektor project to work with.
  --language TEXT  The UI language to use (overrides autodetection).
  --version        Show the version and exit.
  --help           Show this message and exit.

Commands:
  build              Builds the entire project into the final...
  clean              Cleans the entire build folder.
  content-file-info  Provides information for a set of lektor files.
  deploy             Deploy the website.
  dev                Development commands.
  plugins            Manages plugins.
  project-info       Shows the info about a project.
  quickstart         Starts a new empty project.
  server             Launch a local server.

オプションに、quickstartをつけると簡単んいプロジェクトが始められるみたいです。

# lektor quickstart

Lektor Quickstart
=================

This wizard will generate a new basic project with some sensible defaults for
getting started quickly.  We just need to go through a few questions so that
the project is set up correctly for you.

Step 1:
| A project needs a name.  The name is primarily used for the admin UI and
| some other places to refer to your project to not get confused if multiple
| projects exist.  You can change this at any later point.
> Project Name: "プロジェクトの名前を入力"

Step 2:
| Your name.  This is used in a few places in the default template to refer
| to in the default copyright messages.
> Author Name ["著者の名前"]:

Step 3:
| This is the path where the project will be located.  You can move a
| project around later if you do not like the path.  If you provide a
| relative path it will be relative to the working directory.
> Project Path ["プロジェクトのパス"]:

Step 4:
| Do you want to generate a basic blog module?  If you enable this the
| models for a very basic blog will be generated.
> Add Basic Blog [Y/n]: Y

That's all. Create project? [Y/n] Y

すぐにプロジェクトが作成され、作成されたフォルダにcdしてtreeコマンドを実行すると作成されたファイルが確認できました。

tree
.
├── プロジェクトの名前.lektorproject
├── assets
│   └── static
│       └── style.css
├── content
│   ├── about
│   │   └── contents.lr
│   ├── blog
│   │   ├── contents.lr
│   │   └── first-post
│   │       └── contents.lr
│   ├── contents.lr
│   └── projects
│       └── contents.lr
├── models
│   ├── blog-post.ini
│   ├── blog.ini
│   └── page.ini
└── templates
    ├── blog-post.html
    ├── blog.html
    ├── layout.html
    ├── macros
    │   ├── blog.html
    │   └── pagination.html
    └── page.html

10 directories, 16 files

ローカルサーバーを起動するには次のコマンドを実行します。
アクセスをするにはブラウザで、http://127.0.0.1:5000/ にアクセスします。

# lektor server

 * Project path: プロジェクトの名前.lektorproject
 * Output path: /Users/*****/Library/Caches/Lektor/builds/7f3059dbd1dd5855e861340204aabf2a
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Started source info update
Finished source info update in 0.03 sec
Started build
U index.html
U about/index.html
U projects/index.html
U blog/index.html
U static/style.css
U blog/first-post/index.html
Finished build in 0.10 sec
Started prune
Finished prune in 0.00 sec

設定を変更するには、http://127.0.0.1:5000/admin/ で管理ページにアクセスする。

あとは感覚で編集できそう。

setup.pyを確認すると、mitsuhikoさんが作っている色々なプロジェクトがベースになってることが、よくわかります、すごい人ですねぇ。

Jinja2>=2.4
Jinja2 is a full featured template engine for Python. It has full unicode support, an optional integrated sandboxed execution environment, widely used and BSD licensed.

作者 trmin Ronacher

click>=6.0
Click is a Python package for creating beautiful command line interfaces in a composable way with as little code as necessary. It’s the “Command Line Interface Creation Kit”. It’s highly configurable but comes with sensible defaults out of the box.

It aims to make the process of writing command line tools quick and fun while also preventing any frustration caused by the inability to implement an intended CLI API.

作者 trmin Ronacher

watchdog
Python API library and shell utilities to monitor file system events.

mistune
The fastest markdown parser in pure Python, inspired by marked.

Flask
Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions. And before you ask: It's BSD licensed!

作者 trmin Ronacher

EXIFRead
Easy to use Python module to extract Exif metadata from tiff and jpeg files.

inifile
A small INI library for Python.

作者 trmin Ronacher

Babel
Babel is an integrated collection of utilities that assist in internationalizing and localizing Python applications, with an emphasis on web-based applications.

setuptools
Easily download, build, install, upgrade, and uninstall Python packages

pip
The PyPA recommended tool for installing Python packages.

requests
Requests is the only Non-GMO HTTP library for Python, safe for human consumption.

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5