GithubHelp home page GithubHelp logo

blendedsitegenerator / blended Goto Github PK

View Code? Open in Web Editor NEW
24.0 5.0 3.0 1.35 MB

The Most Versatile Static HTML Site Generator

Home Page: http://jmroper.com/blended/

License: GNU General Public License v3.0

Python 99.84% Batchfile 0.16%
website-generation python html markdown restructured-text plain-text microsoft-word textile static static-site

blended's Introduction

Blended

Blended is a static website generator written in Python and licensed under the GPL 3.0 open-source license. It supports a HTML-based templating system, content written in HTML, Markdown, Textile, reStructuredText, Jade, Docx, and Plain Text. It also supports the compilation of SASS, Less, Stylus, and CoffeeScript. Blended makes it easy to deploy your websites by including a built-in FTP uploader. In addition, Blended is powerfully upgradeable because it has support for a Python plugin system.

Installing

To install Blended from PyPi (recommended) run:

pip install blended

To build and install Blended from source run:

git clone https://github.com/johnroper100/Blended.git

cd Blended

pip install .

Running

To use Blended after you have installed it, run:

blended init

This will help you start up a new website. If you need help, run:

blended --help

and you will see all of the commands that are available.

Building Your Site

To build the site you have created with Blended run

blended build

or

blended interactive (for on file change building)

For any command that you run, you can specify an alternative --outdir to build or view from. For example, to build to the source_output folder, run blended build --outdir source_output.

Inside the config.py file, you can set minify_css and minify_js to true to optimize your CSS and JS files after building.

Working With templates

You can install templates from GitHub using blended install-template.

Each Blended website uses four template files:

  • header.html (Required)
  • footer.html (Required)
  • home_page.html (Not required but the site looks better)
  • content_page.html (Not required but the site looks better)
  • nav(name).html (You can have up to 6 different nav templates. For example, navTest.html or nav_test.html)
  • page_list_item.html (Not required, if used, this will replace each page list item content. Can have the variables {name}, {content}, {content_short}, {date}, {day}, {month}, {month_name} {year}, {path})

In these files you place the markup for each section to be generated.

When working with pages, you can optionally specify which template you want (other than content_page.html) by adding the name of the template file without the extension to the first line of the page, and then at least five +s to the second line. For example, if I wanted to use a template called blog_page.html for a certain page, I would put

blog_page
+++++

at the top of the page. Make sure you put it at the top or else it will not work!

You have some variables that you can use in your templates to pull in values while building:

  • {website_name}
  • {website_description}
  • {website_description_long} (Use for long descriptions like an author bio)
  • {author_name}
  • {author_bio}
  • {website_language}
  • {website_license}
  • {website_url}
  • {page_content} (Can only be used in the content_page.html template file)
  • {page_date} (Date/Time the page was written/modified)
  • {page_day} (Day the page was written/modified)
  • {page_month} (Month the page was written/modified)
  • {page_month_name} (Name of the month the page was written/modified)
  • {page_year} (Year the page was written/modified)
  • {relative_root} (Returns a relative path for the current file)
  • {random_number}
  • {build_date}
  • {build_time}
  • {build_datetime}
  • {(page_filename)_active} (When building, if the active page equals the filename in the tag, the tag is replaced by active ex. {getting-started.html_active})
  • {nav(name)} (Use to place navbars. To add a navbar, write nav plus something else. For example, {nav2} or {nav_test})
  • {page_list} (Lists all the pages in <ul><li><a href="page-name.html">page-name</a></li></ul> format)
  • {page_file} (The full filename of the page. ex. getting-started.html)
  • {page_filename} (the filename of the page without the .html extension. ex. getting-started)
  • {page_name} (Gives the name of the current page. Makes the page name look more pretty. For example, getting-started.html is converted to Getting Started)
  • {page_folder} (Gives the name of the current page's folder. Makes the folder name look more pretty. For example, getting-started is converted to Getting Started)
  • {page_folder_orig} (Gives the name of the current page's folder)
  • {blended_version} (Gives Blended's current version)
  • {blended_version_message} (Gives Blended's current version with a nice message: Built with Blended v4.9)

Wherever you put these variables in the templates, they will be replaced by the values in your config.py file. The variables must stay within the curley brackets. You can even put variables inside the content of other variables!

Working With Plugins

You can install plugins from PyPi, for example pip install blended_google_analytics. You can also install plugins from GitHub using blended install-plugin.

To use plugins, include them in the plugins list in config.py.

If the plugin is meant to be called in your templates, ex. {html_comment_box} then insert it into the plugins list like plugins = ["html_comment_box"].

You can use multiple plugins at once, ex. plugins = ["html_comment_box", "minify_images"]

Working With Custom Variables

Inside of your config.py there is a variable custom_variables = {}. This is a dictionary of all of the custom variables you would like to use. To add a variable, add it as a dictionary item.

Here are some examples:

custom_variables = {"software_name": "Blended"}

custom_variables = {"software_name": "Blended", "software_version": "5.0"}

Importing from WordPress

You can import a website and posts from WordPress. To do so, export from WordPress using the Posts option and download the file to the directory where you want to generate your website.

Run the command blended import-wp and it will prompt you for the name/file path of the file. Type in the filename and Blended will create a new website with the information.

Importing from Blogger

You can import posts from Blogger. To do so, export from Blogger using the Backup Site option and download the file to the directory where you want to generate your website.

Run the command blended import-blogger and it will prompt you for the name/file path of the file. Type in the filename and Blended will create a new website with the information.

Pre-Made Templates

Remember that you can install templates from GitHub using blended install-template.

Plugins

Projects That Use Blended

blended's People

Contributors

johnroper100 avatar rpalo 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

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

rpalo uerenyldz

blended's Issues

Python 3 PIP error: "importlib.util module does not exist"

When doing pip install blended to do a local build of https://github.com/ArtOfIllusion/AOI-website I got the above error. (thanks for the contribution, BTW!)

I was able to replicate the error by running pip install importlib. I'm on arch, so my default python package is python 3. I've done some poking around, and found that the importlib module seems to be intended for use with python 2.x only?

I was able to install a secondary package for python 2.7, and was able to successfully install and run blended with that. However, since the blended website states that blended is for use with both python 2 & 3, I thought I'd drop a line here, just in case I'm missing something.

Recursion

It seems that Blended processes content items in the content directory, but not in subdirectories.

Unknown python execution error after running 'blended init'

I receive the following error when attempting to run 'blended init' with no easily identifiable way to resolve the error message:

[root@localhost]# blended init
Traceback (most recent call last):
  File "/bin/blended", line 7, in <module>
    from blended.__main__ import cli
  File "/usr/lib/python3.4/site-packages/blended/__main__.py", line 34, in <module>
    from .functions import create_folder, replace_folder, get_html_filename, get_html_clear_filename, getunzipped, checkConfig, createConfig, createBlendedFolders, parseXML
  File "/usr/lib/python3.4/site-packages/blended/functions.py", line 76
    except IOError, e:
                  ^
SyntaxError: invalid syntax

"blended build" encounter error

hi.

root@AR:/usr/local/blended-site# cat content/test-3.md

测试3

这是测试3.
root@AR:/usr/local/blended-site#
root@AR:/usr/local/blended-site# blended build
Building your Blended files into a website!
Traceback (most recent call last):
File "/usr/local/bin/blended", line 11, in
sys.exit(cli())
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 664, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 644, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 991, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 837, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 464, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/blended/main.py", line 559, in build
build_files()
File "/usr/local/lib/python2.7/dist-packages/blended/main.py", line 397, in build_files
text_cont1 = convert_text(os.path.join(root, filename))
File "/usr/local/lib/python2.7/dist-packages/blended/main.py", line 251, in convert_text
text_cont1 = "\n"+markdown.markdown(text_content.read())+"\n"
File "/usr/local/lib/python2.7/dist-packages/markdown/init.py", line 494, in markdown
return md.convert(text)
File "/usr/local/lib/python2.7/dist-packages/markdown/init.py", line 359, in convert
source = util.text_type(source)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 2: ordinal not in range(128). -- Note: Markdown only accepts unicode input!
root@AR:/usr/local/blended-site#

test-3.md is written in chinese.how to fix the error?

Build problems with 4.1

Unfortunately, 4.1 yields errors:
Building your Blended files into a website!
Traceback (most recent call last): File "/bin/blended", line 11, in sys.exit(cli()) File "/usr/lib/python2.7/site-packages/click/core.py", line 722, in call return self.main(*args, **kwargs) File "/usr/lib/python2.7/site-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/usr/lib/python2.7/site-packages/click/core.py", line 1066, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/lib/python2.7/site-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/lib/python2.7/site-packages/click/core.py", line 535, in invoke return callback(*args, **kwargs) File "/usr/lib/python2.7/site-packages/blended/main.py", line 547, in build build_files() File "/usr/lib/python2.7/site-packages/blended/main.py", line 469, in build_files file_modified = str(time.ctime(os.path.getmtime(subfolder_folder))) File "/usr/lib64/python2.7/genericpath.py", line 62, in getmtime return os.stat(filename).st_mtime OSError: [Errno 2] No such file or directory: '/home/jv/src/tt2site/Sites/JohanVromans/blended/build/foo/coloured_notes.html'

Note that there is no source content/foo/coloured_notes.html, so I wonder why it wants to put it in build.

build fails with error: "name 'reload' is not defined"

On (MacOS High Sierra) Python 3.6.4, fresh install and creation of a Blended site, I get this error on build :

Traceback (most recent call last): File "/usr/local/bin/blended", line 11, in <module> load_entry_point('blended==5.0.2', 'console_scripts', 'blended')() File "/usr/local/lib/python3.6/site-packages/click/core.py", line 722, in __call__ return self.main(*args, **kwargs) File "/usr/local/lib/python3.6/site-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.6/site-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke return callback(*args, **kwargs) File "/usr/local/lib/python3.6/site-packages/blended/__main__.py", line 723, in build reload(sys) NameError: name 'reload' is not defined

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.