perun

所属分类:前端开发
开发工具:Clojure
文件大小:0KB
下载次数:0
上传日期:2022-07-31 16:34:08
上 传 者sh-1993
说明:  使用Clojure和Boot构建的可编程静态站点生成器(需要帮助!)
(Programmable static site generator built with Clojure and Boot (HELP NEEDED!))

文件列表:
.circleci/ (0, 2020-12-23)
.circleci/config.yml (4498, 2020-12-23)
CHANGELOG.md (372, 2020-12-23)
CONTRIBUTING.md (1158, 2020-12-23)
Dockerfile (1175, 2020-12-23)
Dockerfile_java11 (130, 2020-12-23)
Dockerfile_test (1115, 2020-12-23)
LICENSE (11515, 2020-12-23)
MAINTAINERS.md (2414, 2020-12-23)
SPEC.md (3531, 2020-12-23)
boot.properties (81, 2020-12-23)
build.boot (1331, 2020-12-23)
docker-compose.yml (178, 2020-12-23)
example-blog/ (0, 2020-12-23)
example-blog/boot.properties (119, 2020-12-23)
example-blog/build.boot (2524, 2020-12-23)
example-blog/resources/ (0, 2020-12-23)
example-blog/resources/2015-04-01-post1.md (3058, 2020-12-23)
example-blog/resources/2015-05-08-post2.md (11537, 2020-12-23)
example-blog/resources/perun.base.edn (106, 2020-12-23)
example-blog/resources/start.js (28, 2020-12-23)
example-blog/src/ (0, 2020-12-23)
example-blog/src/io/ (0, 2020-12-23)
example-blog/src/io/perun/ (0, 2020-12-23)
example-blog/src/io/perun/example/ (0, 2020-12-23)
example-blog/src/io/perun/example/about.clj (537, 2020-12-23)
example-blog/src/io/perun/example/assortment.clj (623, 2020-12-23)
example-blog/src/io/perun/example/index.clj (785, 2020-12-23)
example-blog/src/io/perun/example/paginate.clj (617, 2020-12-23)
example-blog/src/io/perun/example/post.clj (577, 2020-12-23)
example-blog/src/io/perun/example/tags.clj (600, 2020-12-23)
examples/ (0, 2020-12-23)
examples/semantic-ui/ (0, 2020-12-23)
examples/semantic-ui/boot.properties (141, 2020-12-23)
examples/semantic-ui/build.boot (3157, 2020-12-23)
... ...

![perun-logo-big](https://github.com/hashobject/perun/blob/master/perun.png) [![Clojars Project](https://github.com/hashobject/perun/blob/master/https://img.shields.io/clojars/v/perun.svg)](https://github.com/hashobject/perun/blob/master/https://clojars.org/perun) [![Dependencies Status](https://github.com/hashobject/perun/blob/master/http://jarkeeper.com/hashobject/perun/status.svg)](https://github.com/hashobject/perun/blob/master/http://jarkeeper.com/hashobject/perun) [![Downloads](https://github.com/hashobject/perun/blob/master/https://jarkeeper.com/hashobject/perun/downloads.svg)](https://github.com/hashobject/perun/blob/master/https://jarkeeper.com/hashobject/perun) Simple, composable static site generator built on top of the [Boot](https://github.com/hashobject/perun/blob/master/http://boot-clj.com/). Inspired by Boot task model and [Metalsmith](https://github.com/hashobject/perun/blob/master/http://www.metalsmith.io/). Perun is a collection of boot tasks that you can chain together and build something custom that suits your needs. Please check out our [Getting Started](https://github.com/hashobject/perun/blob/master/https://perun.io/guides/getting-started/) guide. # HELP NEEDED! This project is currently unmaintained! Want to help? Please see [#241](https://github.com/hashobject/perun/blob/master/#241). ## For information and help [Clojurians slack](https://github.com/hashobject/perun/blob/master/https://clojurians.slack.com/) ([join](https://github.com/hashobject/perun/blob/master/http://clojurians.net/)) has a channel [#perun](https://github.com/hashobject/perun/blob/master/https://clojurians.slack.com/messages/perun/) for talk about Perun. Check [SPEC.md](https://github.com/hashobject/perun/blob/master/./SPEC.md) for documentation about metadata keys used by built-in tasks. ## Plugins See the [Built-Ins Guide](https://github.com/hashobject/perun/blob/master/https://perun.io/guides/built-ins/) for a list of built-in tasks. ## 3rd party useful plugins There are plenty of Boot plugins that can be useful in the when you are using perun: - [boot-http](https://github.com/hashobject/perun/blob/master/https://github.com/pandeiro/boot-http) - serve generated site locally using web server - [boot-gzip](https://github.com/hashobject/perun/blob/master/https://github.com/martinklepsch/boot-gzip) - gzip files - [boot-s3](https://github.com/hashobject/perun/blob/master/https://github.com/hashobject/boot-s3) - sync generated site to the Amazon S3 - [boot-less](https://github.com/hashobject/perun/blob/master/https://github.com/Deraen/boot-less) - task to compile Less to CSS - [boot-sassc](https://github.com/hashobject/perun/blob/master/https://github.com/mathias/boot-sassc) - task to compile Sass to CSS - [boot-garden](https://github.com/hashobject/perun/blob/master/https://github.com/martinklepsch/boot-garden) - task to compile Garden stylesheets to CSS - [boot-autoprefixer](https://github.com/hashobject/perun/blob/master/https://github.com/danielsz/boot-autoprefixer) - add vendor prefixes to your CSS - [boot-reload](https://github.com/hashobject/perun/blob/master/https://github.com/adzerk-oss/boot-reload) - live-reload of browser Cljs, HTML, CSS and images (Requires Cljs). - [boot-livereload](https://github.com/hashobject/perun/blob/master/https://github.com/deraen/boot-livereload) - live-reload of browser JS, HTML, CSS and images. - [boot-hyphenate](https://github.com/hashobject/perun/blob/master/https://github.com/deraen/boot-hyphenate) - hyphenate HTML files with soft-hyphens. ## Version Perun is currently tested against Boot `2.8.2`. Higher versions are blocked by https://github.com/boot-clj/boot/issues/745. ## Plugins system Everything in perun is build like independent task. The simplest blog engine will look like: ```clojure (deftask build "Build blog." [] (comp (markdown) (render :renderer renderer))) ``` But if you want to make permalinks, generate sitemap and rss feed, hide unfinished posts, add time to read to each post then you will do: ```clojure (deftask build "Build blog." [] (comp (markdown) (draft) (ttr) (slug) (permalink) (render :renderer renderer) (sitemap :filename "sitemap.xml") (rss :site-title "Hashobject" :description "Hashobject blog" :base-url "http://blog.hashobject.com/") (atom-feed :site-title "Hashobject" :description "Hashobject blog" :base-url "http://blog.hashobject.com/") (notify))) ``` You can also chain this with standard boot tasks. E.x. if you want to upload generated files to Amazon S3 you might use [boot-s3](https://github.com/hashobject/perun/blob/master/https://github.com/hashobject/boot-s3) plugin. Then your code might look like this: ```clojure (deftask build "Build blog." [] (comp (markdown) (render :renderer renderer) (s3-sync))) ``` ## Use cases - Generate blog from markdown files. - Generate documentation for your open source library based on README. - Any case where you'd want to use Jekyll or another static site generator. ## Examples [A minimal blog example](https://github.com/hashobject/perun/blob/master//example-blog/), included in this repo. See [build.boot](https://github.com/hashobject/perun/blob/master//example-blog/build.boot) Real-world websites created with perun: - [perun.io](https://github.com/hashobject/perun/blob/master/https://perun.io). See [build.boot](https://github.com/hashobject/perun/blob/master/https://github.com/hashobject/perun.io/blob/master/build.boot) - [blog.hashobject.com](https://github.com/hashobject/perun/blob/master/http://blog.hashobject.com). See [build.boot](https://github.com/hashobject/perun/blob/master/https://github.com/hashobject/blog.hashobject.com/blob/master/build.boot) - [code.hashobject.com](https://github.com/hashobject/perun/blob/master/http://code.hashobject.com). See [build.boot](https://github.com/hashobject/perun/blob/master/https://github.com/hashobject/code.hashobject.com/blob/master/build.boot) - [deraen.github.io](https://github.com/hashobject/perun/blob/master/http://deraen.github.io/). See [build.boot](https://github.com/hashobject/perun/blob/master/https://github.com/Deraen/deraen.github.io/blob/blog/build.boot) - [eccentric-j.com](https://github.com/hashobject/perun/blob/master/https://eccentric-j.com). See [build.boot](https://github.com/hashobject/perun/blob/master/https://github.com/eccentric-j/idle-parens/blob/master/build.boot) - [www.martinklepsch.org](https://github.com/hashobject/perun/blob/master/http://www.martinklepsch.org/). See [build.boot](https://github.com/hashobject/perun/blob/master/https://github.com/martinklepsch/martinklepsch.org/blob/master/build.boot) - [presumably.de](https://github.com/hashobject/perun/blob/master/https://presumably.de/). See [build.boot](https://github.com/hashobject/perun/blob/master/https://github.com/pesterhazy/presumably/blob/master/build.boot) - [nicerthantriton.com](https://github.com/hashobject/perun/blob/master/https://nicerthantriton.com/). See [build.boot](https://github.com/hashobject/perun/blob/master/https://github.com/bhagany/nicerthantriton.com/blob/master/build.boot) - [200ok.ch](https://github.com/hashobject/perun/blob/master/http://200ok.ch). See [build.boot](https://github.com/hashobject/perun/blob/master/https://gitlab.200ok.ch/200ok/200ok.ch/blob/master/build.boot) - [sooheon.org](https://github.com/hashobject/perun/blob/master/http://sooheon.org). See [build.boot](https://github.com/hashobject/perun/blob/master/https://github.com/sooheon/sooheon.org/blob/master/build.boot) - [ballpointcarrot.net](https://github.com/hashobject/perun/blob/master/http://ballpointcarrot.net). See [build.boot](https://github.com/hashobject/perun/blob/master/https://github.com/ballpointcarrot/ballpointcarrot.github.io/blob/master/.perun/build.boot) - [jstaffans.github.io](https://github.com/hashobject/perun/blob/master/https://jstaffans.github.io). See [build.boot](https://github.com/hashobject/perun/blob/master/https://github.com/jstaffans/jstaffans.github.io/blob/static-perun/build.boot) - [www.clojurebridgemn.org](https://github.com/hashobject/perun/blob/master/http://www.clojurebridgemn.org/). See [build.boot](https://github.com/hashobject/perun/blob/master/https://gitlab.com/clojurebridge-mn/clojurebridgemn.org/blob/master/build.boot) ## How does it work Perun works in the following steps: 1. Read all the files from the source directory and create fileset metadata `(:metadata (meta fileset)` with all meta information available for all tasks/plugins 2. Call each perun task/plugin to manipulate the fileset metadata 3. Write the results to the destination/target directory Perun embraces Boot task model. Fileset is the main abstraction and the most important thing you should care about. When you use perun you need to create custom task that is a composition of standard and 3d party tasks/plugins/functions. Perun takes set of files as input (e.x. source markdown files for your blog) and produces another set of files as output (e.x. generated deployable html for your blog). Fileset passed to every task has metadata `(:metadata (meta fileset)`. This metadata contains accumulated information from each task. More info about structure of this metadata is coming. ## Install ```clojure [perun "0.3.0"] ``` ## Usage Create `build.boot` file with similar content. For each task please specify your own options. See documentation for each task to find all supported options for each plugin. ```clojure (set-env! :source-paths #{"src"} :resource-paths #{"resources"} :dependencies '[[org.clojure/clojure "1.7.0"] [hiccup "1.0.5"] [perun "0.2.0-SNAPSHOT"] [clj-time "0.9.0"] [hashobject/boot-s3 "0.1.2-SNAPSHOT"] [jeluard/boot-notify "0.1.2" :scope "test"]]) (task-options! pom {:project 'blog.hashobject.com :version "0.2.0"} s3-sync { :bucket "blog.hashobject.com" :source "resources/public/" :access-key (System/getenv "AWS_ACCESS_KEY") :secret-key (System/getenv "AWS_SECRET_KEY") :options {"Cache-Control" "max-age=315360000, no-transform, public"}}) (require '[io.perun :refer :all]) (require '[hashobject.boot-s3 :refer :all]) (require '[jeluard.boot-notify :refer [notify]]) (defn renderer [{global :meta posts :entries post :entry}] (:name post)) (defn index-renderer [{global :meta files :entries}] (let [names (map :title files)] (clojure.string/join "\n" names))) (deftask build "Build blog." [] (comp (markdown) (draft) (ttr) (slug) (permalink) (render :renderer renderer) (collection :renderer index-renderer :page "index.html") (sitemap :filename "sitemap.xml") (rss :site-title "Hashobject" :description "Hashobject blog" :base-url "http://blog.hashobject.com/") (s3-sync) (notify))) ``` After you created `build` task simply do: ```bash boot build ``` ## Tips ### Debug To see more detailed output from each task (useful for debugging) please use `--verbose` boot flag. E.x. `boot --verbose dev` ### Development setup Perun is static site generator. So usually you'd use it by just running `boot build` which will generate your static site. This process is robust and great for production but it's slow and lacks fast feedback when you're developing your site locally. In order to solve this problem we recommend following setup: 1. Have 2 separate tasks for building local version and production version. E.x. `build-dev` and `build`. 2. Include [boot-http](https://github.com/hashobject/perun/blob/master/https://github.com/pandeiro/boot-http) into your `build.boot` file. This will enable serving your site using web server. 3. Create task `dev` that will call `build-dev` on any change to your source files: ```clojure (deftask dev [] (comp (watch) (build-dev) (serve :resource-root "public"))) ``` 4. Run`boot dev` In such setup you will have HTTP web server serving your generated content that would be regenerated every time you change your source files. So you'd be able to preview your changes almost immediately. ### Auto deployment It's quite easy to setup automatic static site deployment. E.x. you have GitHub repo for your blog and you are using `boot-s3` to sync files to Amazon S3. In this case it's possible to setup flow in a way that every commit to GitHub would be built on Heroku using perun and deployed to AWS S3. Assuming you have setup similar to [example](https://github.com/hashobject/perun/blob/master/https://github.com/hashobject/blog.hashobject.com/blob/master/build.boot#L31) in order to achieve this you need to: - create [Heroku](https://github.com/hashobject/perun/blob/master/heroku.com) application for your GitHub repo with `build.boot` file - ensure that `build.boot` has `build` task that has tasks build and deploy tasks - specify `AWS_ACCESS_KEY` and `AWS_SECRET_KEY` envs. They are mandatory for the `boot-s3` plugin). - add boot/perun buildpack `heroku buildpacks:add https://github.com/hashobject/heroku-buildpack-perun` - enable GitHub integration https://devcenter.heroku.com/articles/github-integration - change your site in GitHub and see changes deployed to AWS S3 in few minutes Similar auto deployment can be configured using [CircleCI](https://github.com/hashobject/perun/blob/master/http://circleci.com) too. ## Contributions We love contributions. Please submit your pull requests. ## Main Contributors - [Martin Klepsch](https://github.com/hashobject/perun/blob/master/https://github.com/martinklepsch) - [Juho Teperi](https://github.com/hashobject/perun/blob/master/https://github.com/Deraen) - [Brent Hagany](https://github.com/hashobject/perun/blob/master/https://github.com/bhagany) ## Copyright and License Copyright 2013-2019 Hashobject Ltd (team@hashobject.com) and [perun Contributors](https://github.com/hashobject/perun/blob/master/https://github.com/hashobject/perun/graphs/contributors). Distributed under the [Eclipse Public License](https://github.com/hashobject/perun/blob/master/http://opensource.org/licenses/eclipse-1.0).

近期下载者

相关文件


收藏者