• Stars
    star
    170
  • Rank 223,357 (Top 5 %)
  • Language
    Lua
  • Created about 12 years ago
  • Updated almost 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A very simple blog engine using openresty, nginx, lua, markdown, git and redis

A Simple nameless blog engine

My motivation was just having a simple no frills blog for publishing some of my latest writings. This project is not very serious and is meant for personal use. The most unusual part about this project is it's usage of nginx as the "app server". This is possible using lua, since there is a nginx lua module that enables you to call lua from the nginx conf. Have a look at openresty's site for more about what it enables you to do. One of the coolest things about Lua is its speed, check out http://www.techempower.com/benchmarks/

The full stack:

Components
  • Lua(jit) Superfast and lean scripting language.
  • Nginx Superfast and lean web server.
  • Openresty A bundle of plugins for nginx letting me run lua code directly in Nginx.
  • Redis In-memory database with disk persist.
  • Git Disitributed version control system.
  • Markdown Lightweight markup language.

Now we know the components in use, so now I can explain how they work togheter. Lua runs inside nginx and is being used as backend as it is being called in the web developer world. There is little to no javascript running in this setup. The backend loads a few templates (header, footer, etc) using Zed Shaw's tiny templating engine from another micro framework in Lua, check it out here: Tir Microframework

The index template looks in the predefined git repository for a list for markdown files, these will be the blog posts, then it runs git log to figure out the date the blog post was created and displays a list.

The blog post template extracts a filename from the URL and loads the corresponding Markdown file. The markdown gets compiled with Niklas Frykholm's Markdown parser written in lua.

Each view has a simple counter in redis, with the primary motivation of showcasing the speed of these pages. The Redis database is not really needed for any functionality.

Publishing a new article is then just the small matter of writing a Markdown file and pushing it to the blog repository and then it will display in the list and have its own permanent URL.

nginx.conf, the Nginx web server configuration

lua_package_path '/home/www/lua/?.lua;;';
server {
  listen 80;
  server_name example.no www.example.no;
  set $root /home/www/;
  root $root;

  # Serve static if file exist, or send to lua
  location / { try_files $uri @lua; }
  # Lua app
  location @lua {
      content_by_lua_file $root/lua/index.lua;
  }
}              

Author

Tor Hveem [email protected]

License and Copyright

This code is licensed under the BSD license.

Copyright (C) 2013, by Tor Hveem [email protected] All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

More Repositories

1

weechat-matrix-protocol-script

A WeeChat script in Lua that implements the matrix.org chat protocol
Lua
352
star
2

Amatyr

Amateur weather graphs using d3 js, watch js, rivets js, lua, postgresql, nginx
JavaScript
136
star
3

openresty-docker

Dockerfile and sample settings for Openresty/Lua development using Docker
Nginx
87
star
4

infping

Parse fping output, store result in influxdb 0.9
Go
65
star
5

lua-resty-letsencrypt

Lua script for Nginx to automatically get certificates from LetsEncrypt CA
Lua
65
star
6

pix

Photo gallery built with Lapis/Moonscript/Lua/PostgreSQL/Redis/Openresty/HTML5/Angular
JavaScript
38
star
7

blag

My blog articles
22
star
8

photongx

A photo gallery with next to no chrome, written in lua deploying with nginx
JavaScript
20
star
9

lapis-docker

Dockerfile for lapis
Shell
15
star
10

saltvirtweb

A simple virt mgmt admin web interface for salt and salt API
12
star
11

states

My salt states
Shell
12
star
12

cubesensor

My own frontend and API for cubesensors
JavaScript
9
star
13

Weechat-scripts

Weechat scripts
Python
8
star
14

lapiswiki

A very simple wiki-like web editor built in Lapis/Moonscript with the WYSIWYG CKEditor
MoonScript
8
star
15

gomirc

Matrix <=> IRC bridge in Go
Go
8
star
16

salt-xmpp

A simple Salt XMPP gateway example
Python
8
star
17

saltibot

IRC bot listening to salt event bus and publishes filtered events and functions to IRC
Python
5
star
18

weechat-docker

Dockerfile for running development version of WeeChat
C
4
star
19

bash

Online Quote DataBase
MoonScript
4
star
20

Nyfyk

HTML5 RSS Reader app. SQLite3+newsbeuter+openresty-backend
Lua
3
star
21

lsurl

Super simple URL shortening service in Lua/MoonScript
MoonScript
2
star
22

ip

A simple web service in Openresty returning information about the HTTP request
HTML
1
star
23

weechat-urls

Flask web project to display URLs from weechat slite database, optimized for tablets
JavaScript
1
star
24

comics

Java
1
star
25

lurls

A link viewer for IRC bot
JavaScript
1
star