Code Monkey home page Code Monkey logo

manufactorum's Introduction

Build Status

Manufactorum

Ever wanted to make a simple website but with the ability to edit text on the fly without SSHing to remote servers and editing files or doing something else overly complicated just to fix a typo? If you are like me, you don't want to use a full-blown CMS for just a bit of HTML, CSS and text that rarely changes because they are huge and generally suck for small websites.

How?

Similar to ye olde days, paths of your website only exist if there is a file for it. If you want a path /about to be available you need to create a file templates/_about.html and fill it with content (note the preceding _). Because Manufactorum is based on Flask we have all the features of Jinja2 available to us. Here's an example for _about.html:

{% extends "master.html" %}

{% block content %}
    <h1>Oi!</h1>
{% endblock %}

This extends the basic HTML5 template master.html (which already exists) and fills the content block. If you now start Manufactorum and navigate to /about, you'll see your website shouting "Oi!" at you. Every other path except for / will result in a 404 error message. Because / is special, there's a special file for it: templates/index.html. You can of course modify it to suit your needs.

There are also custom template tags which make blocks of text editable by admins. More on that further down.

Custom template tags

text_content

This tag lets you include a HTML snippet form content/ that becomes editable when logged in. Use it like this: {{ text_content('contact_info.html')|safe }}. Note the |safe filter.

This tag uses TinyMCE to make text editable. If you safe your changes, the original file is overwritten.

markdown_content

This tag includes a GitHub Markdown file and parses it. Works the same as text_content but the text is not editable (for now).

Settings

There are some settings you can modify. To do that, create a file settings.cfg. You can look up values to change in default_settings.cfg. I highly encourage you to change SECRET_KEY to a random string. If you don't do this, your installation will be vulnerable to CSRF attacks. Your should treat default_settings.cfg as a read-only file in case you want to look up the defaults.

Caching

Caching is enabled by default and requires a running version of redis. It greatly improves rendering times because templates are not rendered every time a request is made. To disable caching, add CACHING_DISABLED = True to your settings.cfg.

Files and directories

templates/master.html

Just a basic HTML 5 template. Make your own pages extend this template.

templates/index.html

This site is always rendered when / is requested by a client.

templates/admin.html

This is the login form for admin users. Don't change it unless you know what you are doing.

templates/text_content.html

Contains the HTML and JavaScript that lets an admin edit text when logged in. Don't change it either.

templates/_*.html

If you create a file _my-site.html the route /my-site becomes available. These files are rendered with Jinja2 and can extend master.html. If you don't extend master.html text editing won't work because all the needed JavaScripts are included there.

content/

This is the directory where you store your Markdown or editable HTML snippets that you can include in your _*.html pages.

Reserved routes

There are some reserved routes that can't become custom pages. These are /login, /logout and /update-text--a POST-only route that allows for text editing.

Utils

There is an executable Python script add_admin.py that lets you do add an admin user. It prompts for a user name and a password. The user name and the salted and hashed password are stored in a a file. users.dat (human readable).

Proper tutorial

WIP

manufactorum's People

Contributors

retzudo avatar

Watchers

James Cloos avatar  avatar

manufactorum's Issues

Create a manage.py

Move the functionality of add_admin.py and run.py into a manage.py with Flask-Script

Blog

Create a template tag that lets users embed a blog similary to existing static site generators. E. g. {{ blog_content('my_blog')|safe }}. my_blog might be a series of markdown files like my_blog-2015-8-11.md, my_blog-2015-11-20.md etc.

Redis sockets

Allow connections to a UNIX socket instead of a TCP connection

Make a python package

Cloning this repo and modifying it is not the best way of doing things. So create a python package with a setup.py, hosting on PyPI and all that.

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.