Coder Social home page Coder Social logo

gusg21 / painless Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 48 KB

A feather-weight static site generator like hyde written in Python :computer: :globe_with_meridians: :smile:

Home Page: http://gusg21.github.io/painless/

License: Apache License 2.0

Python 61.01% Batchfile 0.53% HTML 37.82% Makefile 0.63%

painless's Introduction

painless Build Status

A feather-weight static site generator like hyde written in Python


painless is a static site generator that feels a lot like hyde, except less sophisticated and pretty easy to use (in my opinion).

Getting started

Downloading

To get set up, clone the repo to your site's directory like so:

git clone http://github.com/gusg21/painless/ super-cool-site

Or you can click the download button and rename the downloaded folder. Your choice.

Folder Layout

The folder structure is like so:

painless
│
│   generate.py
│   painless.bat
│   painless.py
│   serve.py
│
├───pages
│       index.md
│
├───serve
│       index.html
│
└───templates
        bottom.html
        top.html

The pages folder is where all of the markdown for each page of your website goes. For instance, the default index.md, when compiled, results in the index.html of the serve folder.

The serve folder is the fully functional html output. This is where you should point your webserver.

The templates folder is the reusable HTML code. This code can be referenced in the markdown for easy use.

Syntax

The syntax for the input files (in the pages folder) are the same as your run-of-the-mill markdown (see mistune). The additions are:

  • Template Reference ~template
  • Comments $ blah blah blah
  • Static Values [[ time ]] (see the wiki)
  • Divs:
.foo
I'm a div!
.

Result:

<div class="foo">
<p>I'm a div!</p>
</div>
  • Spans:
..foo
I'm a span!
..

Results:

<span class="foo">
<p>I'm a span!</p>
</span>

pages/index.md:

~header

I'm markdown content! _Yay_!

templates/header.html:

<h1>Site Name<h1>
<div class="nav">
  <a href="about">About</a>
</div>

And the resulting index.html would be:

<h1>Site Name<h1>
<div class="nav">
  <a href="about">About</a>
</div>

<p>I'm markdown content! <i>Yay</i>!</p>

A cool Jinja-like feature implemented in painless is argument passing. You can do this:

~import:header arg=value

Template header.html:

<p>{{ arg }}</p>

Result:

<p>value</p>

Testing your site

To test and serve your site, navigate to the folder with painless.py in it and type:

python painless.py gen

Then type:

python painless.py serve

And visit http://localhost:8000/ in your browser of choice.

Note: If you're running Windows, instead of typing "python painless.py" you can type "painless", and it will run painless.bat instead.

API

There is a simple API coded into painless, which you can access by importing painless.py.

# All API functions are prefixed with "API_".

import painless

print(painless.API_getVersion()) # get painless' version

painless.API_serve() # uses config variables
painless.API_serve(PORT=1234) # or provide your own

License

See LICENSE.

painless's People

Stargazers

Angus Goucher avatar

Watchers

James Cloos avatar Angus Goucher avatar  avatar

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.