Giter VIP home page Giter VIP logo

org-site's Introduction

org-site: static site generator based on Emacs Org-mode

Announcement

This project has been stopped as an experimentation to write a static site generator with Emacs Lisp. But still, I’ll keep the code here, just for demo.

I’ve found it’s not convenient to write such a thing with Emacs Lisp since I have to do a lot of hack such as defadvice and with-temp-buffer, etc to match out necessary part from org-mode files.

I’ve switched to Nanoc for my personal website, which is also used by GitHub for its GitHub Developer and GitHub Help.

If you still want a org-mode elisp-based solution, then org-page may be the only choice.

Thanks.

Introduction

Org-site is a static site generator based on Emacs org-mode. http://xiaohanyu.github.io/org-site/ provide a sample GitHub Pages hosted site generated by org-site.

It’s not designed to be a so-called static blog generator, however, org-site will support some simple wiki-like site generation.

Features of org-site:

  1. A convenient workflow without leaving Emacs
  2. Flexible template and theme design, with a default twitter bootstrap theme
  3. Automatic index page generation
  4. Commenting using disqus
  5. Easily switching between multiple org-site projects

Installation

Install libs

Org-site depends on some extra elisp libraries, to install these dependencies, I recommend you install el-get first, and then evaluate the following elisp code snippet in *scratch* buffer by typing C-j, C-x C-e or M-x eval-print-last-exp:

(let ((el-get-sources))
  (add-to-list 'el-get-sources
               '(:name org-site
                       :type github
                       :depends (mustache)
                       :pkgname "xiaohanyu/org-site"))
  (el-get 'sync (mapcar 'el-get-source-name el-get-sources))
  (require 'org-site))

That’s all, now let’s create our first org-site.

Usage

Org-site provides following shortcut commands to facilitate your workflow:

  • org-site-new-project: create a new org-site project.
  • org-site-load-project: load an existing org-site project and set it to the current org-site project.
  • org-site-new-post: create a new post page.
  • org-site-new-wiki: create a new wiki page.
  • org-site-publish: publish org-site to html site, other formats like pdf will be supported in future.

The basic workflow is org-site-new-project or org-site-load-project, then org-site-new-post, org-site-new-wiki, and then finally org-site-publish, that’s it.

Org-site internals

The basic directory structure of org-site project

When you org-site-new-project, you will get the following directory structure:

about.org		# about page of your site
index.org		# index page of your site
org-site-config.el	# org-site project config file
post			# post directory
wiki			# wiki directory

In org-site-config.el, you should set your basic information about your site, such as site url, site title, author name and email, disqus url/identifier, etc.

There’re two types of page in org-site, post and wiki. Generally, posts are updated one by one, while wikis are updated little by little. Later version of org-site will add some more flexible feature support and differentiation to these two different pages, but currently org-site treat them different but handle them the same.

Things about code

org-site is based heavily on org-mode, especially on org-publish and org-export-as-*. Internally, org-site do some monkey patching to org-export-as-* to support mustache template rendering, thus provide a flexible theme and customization support.

Tips

Preview your org-site in localhost

If you want to publish your org-site to public, you must set org-site-url to your real site url, see https://github.com/xiaohanyu/org-site/blob/gh-sources/org-site-config.el for a live example.

If you just want to preview your org-site in localhost, you can set org-site-url to “localhost”, then use things like python -m SimpleHTTPServer to provide a simple http localhost site.

Dependencies

  1. Emacs: Of course it needs Emacs
  2. Org mode: Another of course
  3. mustache.el: org-site use mustache as its template render engine.

And mustache.el depends following libs, so:

  1. ht.el: The missing hash table utility library for Emacs.
  2. loop.el: friendly imperative loop structures for Emacs lisp
  3. s.el: The long lost Emacs string manipulation library.
  4. dash.el: A modern list library for Emacs. This is required by mustache.el, not by org-site directly.

Todo

Feature enhancement

  • Add exportable pdf support
  • RSS export
  • Customizable TOC(Table of Contents)
  • Sidebar?
  • Org-mode code weave/tangle to support literate programming
  • A copiable, collapsible code block
  • Configurable org html source
  • Some more theme?
  • Site statistics, gravatar, etc.
  • Post Category/Tag support
  • Math/TeX/MathJax test and support
  • Localhost/Production support?
  • Search engine support

Project enhancement

  • Add an impressive(I hope that) github page generated by org-site itself, yeah.
  • Documentation work.
  • TDD support based on elisp ERT?

org-site's People

Contributors

xiaohanyu 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

org-site's Issues

Reduce dependences

I think, it depends too many 3rd-party libraries. Could you just merge functions from these libraries? If it just depends on emacs and org-mode, that will be very nice.

Theme and design refinement

Design

Current theme still has lots flaws and bugs, which may need some refinement and
redesign. For example, the TOC anchor doesn't locate to the right section due to
css margin.

Implementation

Pluskid's blog is really a good design using bootstrap, see
http://freemind.pluskid.org/, I'll import some elements from it.

site statistics, site search

Design

Static site need third-party tools to facilitate things like comments,
statistics, site search, etc. Org-site already has support for comments using
disqus, but still lacks support for site statistics, search engine, gravartar,
etc.

Implementation

  • site statistics: google site?
  • site search: google customize search?

org-site local/public publish support

Design

When you write page using org-site, most time you work with localhost, you need
quick site preview, quick publish to localhost, quick page modification and
refinement. You publish your site to public when you feel 100% comfortable with
your work.

That means you need a complete working environment which just works in
localhost, such as necessary css/js files of jquery/bootstrap/mathjax, etc. But
org-site don't really need this css/js files when publish to public, all it need
is some links to the official file links, something like
http://code.jquery.com/jquery-2.0.0.min.js. You don't want the compressed js
files to pollute your tuned org-site source files, right?

Implementation

  • Add an optional argument org-site-mode to org-site-publish, which can be
    assigned to localhost or public, and the default value is
    localhost. When org-site-mode is localhost, set all css/js links to
    local disk css/js files, else, set all css/js files link to official public
    links. Pretty simple, ha.

Code block enhancement

Design

code block need some extra enhancement to make it work more fluent:

  • it should be copiable with a single click
  • it should be collapsible with a single click
  • configurable line number support

Implementation

I guess these minor features need some work with js, which I'm not familiar
with, so, lots of learning work.

MathJax support

Design

Math support is important for science and technical writings. Org-mode have
math support through a LaTeX syntax, while export to html, org-mode invoke
MathJax for html rendering.

But MathJax itself is too big to be include locally as bootstrap/jquery by
org-site, so when preview html in =localhost= mode, we use a fallback
dvipng strategy provided by org-mode.

Implementation

  • Add MathJax cdn link when org file contains math.
  • Functions to check whether or not an org file contains math.
  • Fallback to dvipng when localhost.

exportable pdf support

Design

This feature is inspired by pluskid, see http://freemind.pluskid.org/misc/printable-version-pdf-of-this-blog/.

In a word, each org article should be provide a downloadable pdf link beside the generated html page, of course, the pdf link should be a configurable option.

Implementation

Since org-mode has built-in support for pdf export, this should not be hard to implement. Problems may raise when considering CJK support, thus we need to define a proper org-to-latex settings.

Optional htmlized org source

Design

org-publish has a :htmlized-source option, with which you can export htmlized
org source together with html files, see
http://orgmode.org/worg/worg-setup.org.html for a live example.

Implementation

The implementation should be easy:

  • Add a :htmlized-source option to org-publish
  • Add proper html links to generated html files

Debug mode support

Design

org-site will generate some index files during org-site-publish process, which
will be deleted by org-site-post-publish process by default. Sometimes, we
need to keep these generated files for debug purpose, so an extra debug option
is needed.

Implementation

Just add a org-site-debug option in org-site-config.el, and set it to nil
by default. Check org-site-debug in related functions.

Category/Tag/Archive support

Design

These feature is not necessary for a static site, but when you use org-site as a
static blog generator, then category/tag/archive is a must.

Implementation

Like auto-generated index, we need some utility function to generate
category/tag/archive page.

home page auto generation support

Design

Currently, the home page of org-site is generated through a user provided
index.org file, this is flexible, while some other people don't like it. They
need something like blog's home page, which can generate home page contains a
list of recently published posts. An example see:
http://freemind.pluskid.org/

Implementation

  • Add functions to get the abstract of posts
  • Add functions to aggregate these abstract to form a home page.

RSS support

Design

RSS support is a must of org-site.

Implementation

I'm not familiar with RSS, so may be there're lots of work to do.

Theme customization guide and some more theme?

Design

Theme support and easy customization is one of the most important design goals
of org-site. Internally, org-site use mustache.el and html template to
generate html pages, these process need a explicit interface guide to facilitate
third-party theme customization, for example, which variable represents:

  • site title
  • site author
  • site url
  • page toc
  • page contents

And based on the detailed, explicit theme customization guide, we can provide
more built-in theme support.

Implementation

These feature contains documentation and coding work, and I think documentation
work is more time-consuming than coding work.

如何首先安装el-get?

hi.

看了你页面https://github.com/xiaohanyu/org-site的Installation部分,我先去访问了https://github.com/dimitri/el-get里面所显示的链接地址http://tapoueh.org/emacs/el-get.html,
然后新建了~/.emacs,放入如下内容:

(require 'el-get)
(add-to-list 'el-get-recipe-path "~/.emacs.d/el-get/recipes")
(setq el-get-verbose t)
;; personal recipes
(setq el-get-sources
'((:name el-get :branch "master")
(:name magit
:before (global-set-key (kbd "C-x C-z") 'magit-status))
(:name expand-region
:before (global-set-key (kbd "C-@") 'er/expand-region))
(:name descbinds-anything
:after (progn
(descbinds-anything-install)
(global-set-key (kbd "C-h b") 'descbinds-anything)))
(:name goto-last-change
:before (global-set-key (kbd "C-x C-/") 'goto-last-change))))
;; my packages
(setq dim-packages
(append
;; list of packages we use straight from official recipes
'(gnus bbdb switch-window vkill google-maps pgdevenv-el
mbsync asciidoc smex geiser xcscope multiple-cursors
anything descbinds-anything pcmpl-git magit-view-file
emacs-goodies-el sicp auto-dictionnary keywiz pandoc-mode
pgsql-linum-format psvn rect-mark crontab-mode icomplete+
php-mode-improved rainbow-delimiters muse deft dpans2texi
markdown-mode color-theme-solarized protobuf-mode paredit)
(mapcar 'el-get-as-symbol (mapcar 'el-get-source-name el-get-sources))))
(el-get 'sync dim-packages)

然后运行emacs --load ~/.emacs就安装el-get成功了吗

customizable TOC support

Design

org-export-as-html will export a simple TOC(Table of Contents) by default, what I want is:

Implementation

  • Do some hack about org-export-as-html, and seperable toc from <body>...</body>, then render it with mustache.el
  • Need some CSS work, js may also needed.

Ert test for some tool functions

Design

At first, I just want org-site to work, which means I should come up with a
workable projects. Now org-site has hundreds line of code, some of the code
is dependent tool functions, which can be unit tested easily. The core of
org-site is not easy to test(may need lots of mock and stubs), but the
tools function need some basic testing work. Travis CI maybe also be
imported in.

Implementation

  • Write some ert test for tool functions.
  • Basic Travis CI support.

RSS support

Design

RSS support is a must of org-site.

Implementation

I'm not familiar with RSS, so may be there're lots of work to do.

Test with org-mode 8.0

Design

Org-mode has reached version 8.0, which is the most disruptive major version
of Org(http://orgmode.org/Changes.html). So maybe there're lots
incompatibities between current org-site and org-mode 8.0.

Implementation

First find out whether or not org-site works with org-mode 8.0, if not,
find the underline issues and make a compatibily layer.

El-get can not find a recipe for package "mustache"

When I evaluate this:

(let ((el-get-sources))
(add-to-list 'el-get-sources
             '(:name org-site
                     :type github
                     :depends (mustache)
                     :pkgname "xiaohanyu/org-site"))
  (el-get 'sync (mapcar 'el-get-source-name el-get-sources))
  (require 'org-site))

I get this:

El-get can not find a recipe for package "mustache"

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.