Code Monkey home page Code Monkey logo

letterpress's Introduction

What's Letterpress?

Letterpress is a minimal, Markdown based blogging system written in Python.

Why Letterpress?

  • Letterpress is lighter than WordPress.
  • Python is prettier than PHP.
  • Static/text is more reliable than dynamic/database.
  • Markdown is more human-friendly than HTML.
  • Math writing is much easier in ASCIIMathML than in MathML.

Requirements

  1. A Linux kernel with inotify support is required to run Letterpress.
  2. Requires Python 3. I want to contribute to the acceleration of the transition from Python 2 to Python 3.
  3. UTF-8 is assumed. The babel of human languages is bad enough, let's at least use the same encoding.

Installation

  1. Install pyinotify.
  2. Copy code/letterpress.py to your Python runtime path.
  3. Copy code/markdown2/lib/markdown2.py to your Python runtime path.
  4. Make a directory to hold your posts — let's call it press_folder — and copy press/* to it.
  5. Make the necessary changes to the templates(title, twitter handle…) and letterpress.config.
  6. Install Pygments if you want to embed code(using GFM's Syntax Highlighting) in your posts.

Usage

$ python letterpress.py path_to_press_folder

How It Works

After launch, Letterpress monitors Markdown files(recognized by the filename extension specified in letterpress.config) in press_folder. When an new Markdown file is detected Letterpress generates a new HTML file from that Markdown file. Similarly, when an existing Markdown file is updated or deleted, Letterpress updates or deletes the corresponding HTML file.

Letterpress also monitors templates. If any change is detected in any of the template files, Letterpress rebuilds the whole site.

Letterpress also monitors subfolders and other files in press_folder but treat them as assets. It maps them directly into site_dir. It means if you make an assets folder and put images there you can reference them in your posts, e.g., ![Big Headshot](/assets/big_headshot.jpg).

Letterpress builds these indices automatically:

  • Home index
  • Archive indices
  • Monthly indices
  • Yearly indices
  • Tag indices

Letterpress writes logs into press_folder so you can easily review what is going on.

Writing

You write posts in such a natural format:

title: Post Title
date: Publishing date in the format specified in letterpress.config. The default format is 01/31/2013.
excerpt: Summary of the post.
tags: math, web

Content of the post…

### Let's have fun with math & physics

$E=m*c^2$

Refer to press/sample_post.md for a complete example.

Naming

The recommended naming scheme for post files is to use post title, directly or shortened. Adding date to file names would result in redundant path segment in permalinks since Letterpress already puts the HTML files under folders named after their publish dates.

Publishing

You can publish posts by putting them in press_folder with whatever method you like, e.g., FTP or rsync. However, I highly recommend Dropbox. This is how you should use Dropbox to publish posts to Letterpress:

  1. Of course you must have a Dropbox account. Let's call it writer's account.
  2. Install Dropbox client on your desktop computer, iPhone, iPad or other devices you write on. Let's call it writing machine.
  3. Sign in your writer's account on your writing machine.
  4. Have the aforementioned press_folder somewhere in Dropbox folder on your writing machine.
  5. Register another Dropbox account. Let's call it publisher's account.
  6. Install Dropbox client on your server. Let's call it publishing machine.
  7. Sign in your publisher's account on your publishing machine.
  8. Share press_folder from your writer's account to your publisher's account.
  9. Now your writing machine's press_folder and publishing machine's press_folder are in sync. Whenever you put a new post into, edit an existing post in, or delete one from, your press_folder on your writing machine, Letterpress will generate, update, or delete the corresponding HTML file in site_dir(configured in letterpress.config) on your publishing machine.

Credits

So I hardly did any thing but glue these awesome things together.

License

Letterpress is licensed under a BSD-3-clause license. See LICENSE for details. You are encouraged to keep the "Powered by Letterpress" footer on your site.

letterpress's People

Contributors

an0 avatar justinabrahms 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  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

letterpress's Issues

UnicodeDecodeError

I am installed Letterpress on a fresh installation of Archlinux running Python3.3. I am getting the following error when I attempt to run letterpress.py for the first time.

I verified my system is set up as UTF-8

Any ideas?

File "letterpress.py", line 114, in __init__
    template = f.read()
  File "/usr/lib/python3.3/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 2352: ordinal not in range(128)

how to correct the posts order?

hi.
i installed ur app: http://lp.brite.biz/ ,and i published a post http://lp.brite.biz/2014/08/community.html after the post http://lp.brite.biz/2014/08/black-spot-on-white-paper.html ,
the post http://lp.brite.biz/2014/08/community.html should be above http://lp.brite.biz/2014/08/black-spot-on-white-paper.html ,right?
so how to correct the posts order?
i try to add 15:32 as follows:

title: 共同体
date: 08/05/2014 15:32
excerpt: read more...
tags: misc

在任何社会体系中,....

but i met error,so how to do?tks

如何把pyinotify安装到python3.3环境下?

hi.

as3:/usr/local/python-3.3.3/lib/python3.3# python3.3 letterpress.py ~/letterpress/press_folder
Traceback (most recent call last):
File "letterpress.py", line 27, in
import pyinotify
ImportError: No module named 'pyinotify'
as3:/usr/local/python-3.3.3/lib/python3.3# pip install pyinotify
Requirement already satisfied (use --upgrade to upgrade): pyinotify in /usr/local/lib/python2.7/site-packages/pyinotify-0.9.4-py2.7.egg
Cleaning up...
as3:/usr/local/python-3.3.3/lib/python3.3#

Using oauth to get dropbox update

This project is one very good solution for dropbox blogging. I have been using http://scriptogr.am/ for my blogging, but I recently discovered that they don't support GFM, and this project isn't so actively maintained. (I didn't receive any reply from them after sending one mail.)

One feature missing from Letterpress is connecting to dropbox. Currently, the workaround is to download dropbox client on the server, which isn't so convenient on some hosting service provider, like Heroku. Therefore, I am curious do you have any plan to add it?
This link does what I have in mind mostly.

AttributeError: 'module' object has no attribute 'format_datetime'

Hello,

i updated my files with last changed and have the following issus:

2015-11-18 20:11:26,719 - INFO - Site configure: {'date_format': '%m/%d/%Y', 'description': "blog", 'title': "blog", 'site_dir': '/var/www/blog/', 'base_url': 'http://url', 'markdown_ext': '.md', 'math_delimiter': '$'}
2015-11-18 20:11:26,722 - INFO - Build site
Traceback (most recent call last):
  File "/usr/lib/python3.2/letterpress.py", line 907, in <module>
    sys.exit(main())
  File "/usr/lib/python3.2/letterpress.py", line 757, in main
    build_site()
  File "/usr/lib/python3.2/letterpress.py", line 755, in build_site
    create_rss_feed(posts)
  File "/usr/lib/python3.2/letterpress.py", line 707, in create_rss_feed
    item_list.append(format(item_template, title=post.title, date=email.utils.format_datetime(post.date), permalink=post.permalink, content=post.content))
AttributeError: 'module' object has no attribute 'format_datetime'

I double check all files and tried installing email via pip/pip-3.2 without any result. Unfortunately i can not find the solution myself.

Best regards!

errors with Arch Linux 64bit?

hey, what ever I do after running "python3 letterpress.py path_to_press_folder" I get:

2014-09-15 18:52:40,890 - INFO - Build site
Traceback (most recent call last):
  File "/home/tester/src/env/bin/letterpress.py", line 869, in <module>
    sys.exit(main())
  File "/home/tester/src/env/bin/letterpress.py", line 721, in main
    build_site()
  File "/home/tester/src/env/bin/letterpress.py", line 715, in build_site
    create_tags(posts)
  File "/home/tester/src/env/bin/letterpress.py", line 540, in create_tags
    with codecs.open(os.path.join(templates_dir, "tags.html"), 'r', 'utf-8') as f:
  File "/home/tester/src/env/lib/python3.4/codecs.py", line 896, in open
    file = builtins.open(filename, mode, buffering)
FileNotFoundError: [Errno 2] No such file or directory: '/home/tester/src/press-folder/templates/tags.html'

and all data in press_folder gets completly deleted... I remember that it worked about half an year ago.. maybe this is related to some changings in python3?

Suitable for one page blog?

Does the archive template support #content tag, or is there any other simple way of creating a blog that lists all the blog posts in one page? :)

I'm a PHP developer with frontend skills yet I'm not familiar with Python. This is very interesting tech 👍

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.