From 8b14a1e5b2ca574fdd4fd2377567ec98a110d4b6 Mon Sep 17 00:00:00 2001 From: Agustin Henze Date: Wed, 13 Mar 2013 20:58:39 -0300 Subject: Imported Upstream version 5.4.2 --- .travis.yml | 7 +- AUTHORS.txt | 2 + CHANGES.txt | 48 +++ README.md | 2 + docs/creating-a-site.txt | 181 ++++++++++ docs/manual.txt | 276 ++++++++------ docs/theming.txt | 4 +- extra_plugins/command_planetoid/__init__.py | 22 +- extra_plugins/task_mustache/__init__.py | 3 +- nikola/conf.py.in | 77 +++- nikola/console.py | 11 - nikola/data/samplesite/files/images/biohazard.png | Bin 0 -> 179 bytes nikola/data/samplesite/listings/hello.py | 3 +- .../data/samplesite/stories/creating-a-theme.meta | 3 + .../data/samplesite/stories/creating-a-theme.txt | 1 + nikola/data/samplesite/stories/quickref.txt | 60 ++-- nikola/data/samplesite/stories/quickstart.txt | 18 +- nikola/data/themes/default/assets/css/theme.css | 7 +- nikola/data/themes/default/assets/js/mathjax.js | 12 + nikola/data/themes/default/bundles | 2 +- nikola/data/themes/default/templates/base.tmpl | 4 + .../data/themes/default/templates/base_helper.tmpl | 13 +- nikola/data/themes/default/templates/gallery.tmpl | 6 +- nikola/data/themes/default/templates/index.tmpl | 3 +- .../themes/default/templates/index_helper.tmpl | 8 +- nikola/data/themes/default/templates/listing.tmpl | 14 +- nikola/data/themes/default/templates/post.tmpl | 14 +- .../data/themes/default/templates/post_helper.tmpl | 31 +- .../data/themes/jinja-default/templates/base.tmpl | 12 +- .../themes/jinja-default/templates/gallery.tmpl | 8 +- .../data/themes/jinja-default/templates/index.tmpl | 4 +- .../themes/jinja-default/templates/listing.tmpl | 2 +- .../data/themes/jinja-default/templates/post.tmpl | 2 - nikola/data/themes/site/README | 2 +- nikola/data/themes/site/assets/css/theme.css | 9 +- nikola/data/themes/site/templates/post.tmpl | 25 -- nikola/filters.py | 17 +- nikola/main.py | 125 +++++++ nikola/nikola.py | 249 +++++++++---- nikola/plugin_categories.py | 66 +++- nikola/plugins/__init__.py | 1 - nikola/plugins/command_bootswatch_theme.py | 57 +-- nikola/plugins/command_build.plugin | 10 - nikola/plugins/command_build.py | 67 ---- nikola/plugins/command_check.py | 67 ++-- nikola/plugins/command_console.py | 32 +- nikola/plugins/command_deploy.py | 8 +- nikola/plugins/command_import_blogger.py | 139 ++++---- nikola/plugins/command_import_wordpress.py | 240 ++++++++----- nikola/plugins/command_init.py | 44 ++- nikola/plugins/command_install_theme.py | 57 +-- nikola/plugins/command_new_post.py | 127 +++++-- nikola/plugins/command_serve.py | 38 +- nikola/plugins/compile_bbcode.py | 8 +- nikola/plugins/compile_html.py | 8 +- nikola/plugins/compile_markdown/__init__.py | 14 +- nikola/plugins/compile_rest/__init__.py | 10 +- nikola/plugins/compile_rest/gist_directive.py | 12 +- .../compile_rest/pygments_code_block_directive.py | 39 +- nikola/plugins/compile_rest/slides.py | 7 +- nikola/plugins/compile_rest/soundcloud.py | 32 ++ nikola/plugins/compile_rest/vimeo.py | 10 +- nikola/plugins/compile_rest/youtube.py | 8 +- nikola/plugins/compile_textile.py | 8 +- nikola/plugins/compile_txt2tags.py | 8 +- nikola/plugins/task_create_bundles.py | 12 +- nikola/plugins/task_indexes.py | 4 +- nikola/plugins/task_redirect.py | 5 +- nikola/plugins/task_render_galleries.py | 11 +- nikola/plugins/task_render_listings.py | 56 ++- nikola/plugins/task_render_rss.py | 4 +- nikola/plugins/task_render_tags.py | 22 +- nikola/plugins/task_sitemap/__init__.py | 26 +- nikola/plugins/task_sitemap/sitemap_gen.py | 2 +- nikola/post.py | 288 ++++++++++++--- nikola/utils.py | 161 ++------- requirements-3.txt | 11 +- requirements.txt | 11 - scripts/nikola | 36 +- setup.py | 4 +- tests/data/translated_titles/conf.py | 397 +++++++++++++++++++++ tests/data/translated_titles/stories/1.txt | 5 + tests/data/translated_titles/stories/1.txt.es | 4 + tests/test_command_import_wordpress.py | 142 ++++++-- tests/test_command_init.py | 15 +- tests/test_integration.py | 157 ++++++-- tests/test_rss_feeds.py | 12 +- tests/test_utils.py | 121 ++++--- tests/wordpress_export_example.xml | 52 +++ 89 files changed, 2753 insertions(+), 1209 deletions(-) create mode 100644 docs/creating-a-site.txt delete mode 100644 nikola/console.py create mode 100644 nikola/data/samplesite/files/images/biohazard.png create mode 100644 nikola/data/samplesite/stories/creating-a-theme.meta create mode 120000 nikola/data/samplesite/stories/creating-a-theme.txt create mode 100644 nikola/data/themes/default/assets/js/mathjax.js delete mode 100644 nikola/data/themes/site/templates/post.tmpl create mode 100644 nikola/main.py delete mode 100644 nikola/plugins/command_build.plugin delete mode 100644 nikola/plugins/command_build.py create mode 100644 nikola/plugins/compile_rest/soundcloud.py mode change 100644 => 100755 setup.py create mode 100644 tests/data/translated_titles/conf.py create mode 100644 tests/data/translated_titles/stories/1.txt create mode 100644 tests/data/translated_titles/stories/1.txt.es diff --git a/.travis.yml b/.travis.yml index b0f9231..c30c430 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,12 +3,15 @@ python: - "2.6" - "2.7" - "3.2" + - "3.3" # command to install dependencies # pip is run inside the script because we need have different requirements for Python 2 / 3. install: - "python install_requirements.py" + - "pip install flake8 --use-mirrors" - "pip install . --use-mirrors" # We run tests and afterwards nikola to see if the command is executable. -script: +script: - nosetests --with-doctest - - nikola + - nikola help + - "flake8 --exit-zero nikola --ignore=E501" diff --git a/AUTHORS.txt b/AUTHORS.txt index 31bc7b7..b241433 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -2,4 +2,6 @@ Roberto Alsina Eduardo Schettino Niko Wenselowski Roman Imankulov +Kay Hayen Zhaojun Meng +Chris “Kwpolska” Warrick diff --git a/CHANGES.txt b/CHANGES.txt index fe55892..376bcdc 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,51 @@ +New in 5.4.2 +============ + +Bugfixes +-------- + +* Fix relative paths when stories is "dropped to root" (Issue #362) +* Pick translated titles in 1-file posts (Issue #365) + +New in 5.4 +========== + +Features +-------- + +* Twitter Card / Open Graph support. +* Smart math support +* New soundcould directive +* Custom "read more" links +* Better time display, timezone support +* Better doit integration (Issue #151) +* Make the whole listings folder browsable (Issue #128) +* New GZIP_FILES/GZIP_EXTENSIONS options to create gzipped copies of some files (Issue #348) +* New optional path parameter to new_post command. +* Wordpress importer: option to not download files +* Wordpress importer: option to squash newlines +* Separated BLOG_URL into SITE_URL and BASE_URL +* Added DISABLED_PLUGINS option (Issue #354) + +Bugfixes +-------- + +* Added missing in default theme templates. +* Wordpress import: Description is left empty if no description is found. +* When running the build command it is now possible to get help. +* Load jQuery before bootstrap in JS bundle (Issue #327) +* Generate valid HTML5 for redirects (Issue #276) +* Fixed "nikola check" +* Fixed internationalized RSS links +* Make commands that need to be run in a site fail gracefully (Issue #342) +* Use localized links on lxml fixer +* Redirections created during the import from wordpress are now written to conf.py +* Stop parsing metadata in post file on first blank line +* Metadata handling cleanups by Tordek +* Fixed blockquote font size inconsistency +* Wordpress Import: Do not break indentation (issue #189) +* Make things work even if SITE_URL has a path (Fix #307) + New in 5.3 ========== diff --git a/README.md b/README.md index 94bba0f..943128f 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ Nikola, a Static Site and Blog Generator In goes content, out comes a website, ready to deploy. +[![Build Status](https://travis-ci.org/ralsina/nikola.png)](https://travis-ci.org/ralsina/nikola) + Why Static Websites? -------------------- diff --git a/docs/creating-a-site.txt b/docs/creating-a-site.txt new file mode 100644 index 0000000..41985c9 --- /dev/null +++ b/docs/creating-a-site.txt @@ -0,0 +1,181 @@ +.. slug: creating-a-site-not-a-blog-with-nikola +.. date: 2013/03/01 12:49:41 +.. tags: nikola, python +.. link: +.. description: + +Creating a Site (Not a Blog) with Nikola +======================================== + +One of the most frequent questions I get about Nikola is "but how do +I create a site that's not a blog?". And of course, that's because the +documentation is heavily blog-oriented. This document will change that ;-) + +Since it started, Nikola has had the capabilities to create generic sites. For example, +Nikola's `own site `_ is a fairly generic one. Let's go +step by step on how you can do something like that. + +As usual when starting a nikola site, you start with ``nikola init`` which creates a +empty semi-configured site:: + + $ nikola init mysite + Created empty site at mysite. + +Then we go into the new ``mysite`` folder, and make the needed changes in the ``conf.py`` +configuration file: + +.. code-block:: python + + + ############################################## + # Configuration, please edit + ############################################## + + + # Data about this site + BLOG_AUTHOR = "Roberto Alsina" + BLOG_TITLE = "Not a Blog" + # This is the main URL for your site. It will be used + # in a prominent link + SITE_URL = "http://notablog.ralsina.com.ar" + BLOG_EMAIL = "ralsina@kde.org" + BLOG_DESCRIPTION = "This is a demo site (not a blog) for Nikola." + + # + # Some things in the middle you don't really need to change... + # + + post_pages = ( + ("pages/*.txt", "", "story.tmpl", False), + ) + +And now we are ready to create our first page:: + + $ nikola new_post -p + Creating New Post + ----------------- + + Enter title: index + Your post's text is at: pages/index.txt + +.. note:: The ``-p`` option in the ``nikola new_post`` command means we are creating a page and not a blog post. + +We can now build and preview our site:: + + $ nikola build + Scanning posts.done! + . render_site:output/categories/index.html + . render_sources:output/index.txt + . render_rss:output/rss.xml + : + : + : [Much more of the same] + + $ nikola serve + Serving HTTP on 127.0.0.1 port 8000 ... + +And you can see your (very empty) site in http://localhost:8000 + +So, what's in that ``pages/index.txt`` file? + +.. code-block:: rest + + .. title: index + .. slug: index + .. date: 2013/03/01 10:26:17 + .. tags: + .. link: + .. description: + + + Write your post here. + +Title is the page title, slug is the name of the generated HTML file +(in this case it would be ``index.html``) the date doesn't matter much in +not-blogs, same for tags and link. Description is useful for SEO purposes +if you care for that. + +And below, the content. By default you are expected to use +`reStructured text `_ but +Nikola supports a ton of formats, including Markdown, plain HTML, BBCode, +Wiki, and Textile. + +So, let's give the page a nicer title, and some fake content. Since the default +Nikola theme (called "site") is based on `bootstrap `_ +you can use anything you like from it: + +.. code-block:: rest + + .. title: Welcome To The Fake Site + .. slug: index + .. date: 2013/03/01 10:26:17 + .. tags: + .. link: + .. description: Fake Site version 1, welcome page! + + + .. class:: hero-unit span6 + + .. admonition:: This is a Fake Site + + It pretends to be about things, but is really just an example. + So, don't click this button, it leads nowhere. + + .. class:: btn + + Click Me! + + + .. class:: span5 + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris non nunc turpis. + Phasellus a ullamcorper leo. Sed fringilla dapibus orci eu ornare. Quisque + gravida quam a mi dignissim consequat. Morbi sed iaculis mi. Vivamus ultrices + mattis euismod. Mauris aliquet magna eget mauris volutpat a egestas leo rhoncus. + In hac habitasse platea dictumst. Ut sed mi arcu. Nullam id massa eu orci + convallis accumsan. Nunc faucibus sodales justo ac ornare. In eu congue eros. + Pellentesque iaculis risus urna. Proin est lorem, scelerisque non elementum at, + semper vel velit. Phasellus consectetur orci vel tortor tempus imperdiet. Class + aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos + himenaeos. + + [And more in the same vein] + +.. admonition:: TIP: Nice URLs + + If you like your URLs without the ".html" then you want to create folders and + put the pages in ``index.html`` inside them. Example:: + + nikola new_post -p pages/foo/index.txt + + which will create a page you could access as "http://yoursite.com/foo" + +And that's it. You will want to change the SIDEBAR_LINKS option to create a reasonable +"menu" for your site, you will want to hack the theme (check ``nikola help bootswatch_theme`` +for a quick & dirty solution), and you may want to add a blog later on, for company news +or whatever. + +.. admonition:: TIP: So, how do I add a blog now? + + First, change the ``post_pages`` option like this: + + .. code-block:: python + + post_pages = ( + ("pages/*.txt", "", "story.tmpl", False), + ("posts/*.txt", "blog", "post.tmpl", True), + ) + + And to avoid a conflict (because blogs try to generate ``/index.html``: + + .. code-block:: python + + INDEX_PATH = "blog" + + Create a post with ``nikola new_post`` and that's it, you now have a blog + in http://yoursite.com/blog (you may want to add links to it in SIDEBAR_LINKS of course). + +You can see the finished site in http://notablog.ralsina.com.ar and its full configuration in +http://ralsina.com.ar/listings/notablog/conf.py.html + +I hope this was helpful! diff --git a/docs/manual.txt b/docs/manual.txt index caf9780..b2290c2 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -1,7 +1,7 @@ The Nikola Handbook =================== -:Version: 5.3 +:Version: 5.4.2 :Author: Roberto Alsina .. class:: alert alert-info pull-right @@ -226,7 +226,7 @@ libxml/xmlversion.h: No such file or directory`` when running ``pip install -r r Debian systems: sudo apt-get install libxml2-dev - sudo apt-get install libxslt1-dev + sudo apt-get install libxslt1-dev RHEL systems: @@ -235,7 +235,7 @@ RHEL systems: Getting Started --------------- -To create posts and pages in Nikola, you write them in one of the supported input formats. +To create posts and pages in Nikola, you write them in one of the supported input formats. Those source files are later converted to HTML The recommended formats are restructured text and Markdown, but there is also support for textile and WikiCreole and even for just writing HTML. @@ -304,21 +304,32 @@ part of the site using task names, for example ``nikola build render_pages``, an Nikola also has other commands besides ``build``:: $ nikola help - Usage: nikola command [options] - + Nikola Available commands: - - nikola bootswatch_theme: Given a swatch name and a parent theme, creates a custom theme. - nikola build: Build the site. - nikola check: Check the generated site - nikola deploy: Deploy the site - nikola import_wordpress: Import a wordpress site from a XML dump (requires markdown). - nikola init: Create a new site. - nikola install_theme: Install a theme into the current site. - nikola new_post: Create a new post. - nikola serve: Start test server. - - For detailed help for a command, use nikola command --help + nikola auto automatically execute tasks when a dependency changes + nikola bootswatch_theme Given a swatch name and a parent theme, creates a custom theme. + nikola build run tasks + nikola check Check links and files in the generated site. + nikola clean clean action / remove targets + nikola console A short explanation. + nikola deploy Deploy the site. + nikola dumpdb dump dependency DB + nikola forget clear successful run status from internal DB + nikola help show help + nikola ignore ignore task (skip) on subsequent runs + nikola import_blogger Import a blogger dump. + nikola import_wordpress Import a wordpress dump. + nikola init Create a Nikola site in the specified folder. + nikola install_theme Install theme into current site. + nikola list list tasks from dodo file + nikola new_post Create a new blog post or site page. + nikola run run tasks + nikola serve Start the test webserver. + nikola strace use strace to list file_deps and targets + + nikola help show help / reference + nikola help show command usage + nikola help show task usage The ``serve`` command starts a web server so you can see the site you are creating:: @@ -340,25 +351,24 @@ Example usage:: Creating a Blog Post -------------------- -A post consists of two files, a metadata file (``post-title.meta``) and a -file containing the contents written in `restructured text `_ -(``post-title.txt``), markdown or HTML. Which input type is used is guessed using -the ``post_compilers`` option in ``conf.py`` but by default, the extensions -supported are: - -.txt .rst - Restructured Text +To create a new post, the easiest way is to run ``nikola new_post``. You will +be asked for a title for your post, and it will tell you where the post's file +is located. -.md .markdown .mdown - Markdown +By default, that file will contain also some extra information about your post ("the metadata"). +It can be placed in a separate file by using the ``-2`` option, but it's generally +easier to keep it in a single location. -.htm .html - HTML +The contents of your post have to be written (by default) in `restructured text `_ +but you can use a lot of different markups using the ``-f`` option. Currently +Nikola supports bbcode, wiki, markdown, html, txt2tags and textile in addition +to restructured text. -The default configuration expects them to be placed in ``posts`` but that can be +You can control what markup compiler is used for each file extension with the ``post_compilers`` +option. The default configuration expects them to be placed in ``posts`` but that can be changed (see below, the post_pages option) -You can just create them in ``posts`` or use a little helper task provided by Nikola:: +This is how it works:: $ nikola new_post Creating New Post @@ -375,19 +385,19 @@ The content of that file is as follows:: .. tags: .. link: .. description: + Write your post here. -The first line is the title. The second one is the pagename. Since often titles will have +The ``slug`` is the pagename. Since often titles will have characters that look bad on URLs, it's generated as a "clean" version of the title. The third line is the post's date, and is set to "now". -You can add three more optional lines. A fourth line that is a list of tags -separated with commas (spaces around the commas are ignored):: +The other lines are optional. Tags are comma-separated. The ``link`` is an original +source for the content, and ``description`` is mostly useful for SEO. - programming, python, fame, fortune +You can add your own metadata fields in the same manner, if you use a theme that +supports them (for example: ``.. author: John Doe``) -A fifth line that's a URL for an original source of the post, and a sixth line -that's the page description. .. note:: The Two-File Format @@ -460,20 +470,21 @@ one in the list if all of them have it set to False. The ``new_post`` command supports some options:: - $ nikola new_post --help - Usage: nikola new_post [options] - + $ nikola help new_post + Purpose: Create a new blog post or site page. + Usage: nikola new_post [options] [path] + Options: - -h, --help show this help message and exit - -p, --page Create a page instead of a blog post. - -t TITLE, --title=TITLE - Title for the page/post. - --tags=TAGS Comma-separated tags for the page/post. - -1 Create post with embedded metadata (single file - format). - -f POST_FORMAT, --format=POST_FORMAT - Format for post (rest or markdown) + -p, --page Create a page instead of a blog post. + -t ARG, --title=ARG Title for the page/post. + --tags=ARG Comma-separated tags for the page/post. + -1 Create post with embedded metadata (single file format) + -2 Create post with separate metadata (two file format) + -f ARG, --format=ARG Markup format for post, one of rest, markdown, wiki, bbcode, html, textile, txt2tags +The optional ``path`` parameter tells nikola exactly where to put it instead of guessing from your config. +So, if you do ``nikola new_post posts/random/foo.txt`` you will have a post in that path, with +"foo" as its slug. Teasers ~~~~~~~ @@ -497,6 +508,11 @@ this behaviour with your ``conf.py``: ``INDEX_TEASERS`` defines whether index page should display the whole contents or only teasers. ``RSS_TEASERS`` works the same way for your RSS feeds. +By default, teasers will include a "read more" link at the end. If you want to +change that text, you can use a custom teaser:: + + .. TEASER_END: click to read the rest of the article + Drafts ~~~~~~ @@ -552,49 +568,14 @@ commented, but just in case, here is a full, `customized example configuration `_ (the one I use for `my site `_) -Adding Files ------------- - -Any files you want to be in ``output/`` but are not generated by Nikola (for example, -``favicon.ico``, just put it in ``files/``. Everything there is copied into -``output`` by the ``copy_files`` task. Remember that you can't have files that collide -with files Nikola generates (it will give an error). - -.. admonition:: Important - - Don't put any files manually in ``output/``. Ever. Really. Maybe someday Nikola - will just wipe ``output/`` and then you will be sorry. So, please don't do that. - -If you want to copy more than one folder of static files into ``output`` you can -change the FILES_FOLDERS option:: - - # One or more folders containing files to be copied as-is into the output. - # The format is a dictionary of "source" "relative destination". - # Default is: - # FILES_FOLDERS = {'files': '' } - # Which means copy 'files' into 'output' - -Post Processing Filters ------------------------ +You surely want to edit these options:: -You can apply post processing to the files in your site, in order to optimize them -or change them in arbitrary ways. For example, you may want to compress all CSS -and JS files using yui-compressor. + # Data about this site + BLOG_TITLE = "Demo Site" + BLOG_URL = "http://nikola.ralsina.com.ar" + BLOG_EMAIL = "joe@demo.site" + BLOG_DESCRIPTION = "This is a demo site for Nikola." -To do that, you can use the provided helper adding this in your ``config.py``:: - - from nikola import filters - - FILTERS = { - ".css": [filters.yui_compressor], - ".js": [filters.yui_compressor], - } - -Where ``filters.yui_compressor`` is a helper function provided by Nikola. You can -replace that with strings describing command lines, or arbitrary python functions. - -If there's any specific thing you expect to be generally useful as a filter, contact -me and I will add it to the filters library so that more people use it. Customizing Your Site --------------------- @@ -602,15 +583,6 @@ Customizing Your Site There are lots of things you can do to personalize your website, but let's see the easy ones! -Basics - You can assume this needs to be changed:: - - # Data about this site - BLOG_TITLE = "Demo Site" - BLOG_URL = "http://nikola.ralsina.com.ar" - BLOG_EMAIL = "joe@demo.site" - BLOG_DESCRIPTION = "This is a demo site for Nikola." - CSS tweaking The default configuration includes a file, ``themes/default/assets/css/custom.css`` which is empty. Put your CSS there, for minimal disruption of the provided CSS files. @@ -643,6 +615,29 @@ Analytics a Google analytics snippet or something similar, but you can really put anything there. + +Adding Files +------------ + +Any files you want to be in ``output/`` but are not generated by Nikola (for example, +``favicon.ico``, just put it in ``files/``. Everything there is copied into +``output`` by the ``copy_files`` task. Remember that you can't have files that collide +with files Nikola generates (it will give an error). + +.. admonition:: Important + + Don't put any files manually in ``output/``. Ever. Really. Maybe someday Nikola + will just wipe ``output/`` and then you will be sorry. So, please don't do that. + +If you want to copy more than one folder of static files into ``output`` you can +change the FILES_FOLDERS option:: + + # One or more folders containing files to be copied as-is into the output. + # The format is a dictionary of "source" "relative destination". + # Default is: + # FILES_FOLDERS = {'files': '' } + # Which means copy 'files' into 'output' + Getting More Themes ------------------- @@ -765,6 +760,28 @@ be stripped. For example ``03_an_amazing_sunrise.jpg`` will be render as *An ama Here is a `demo gallery `_ of historic, public domain Nikola Tesla pictures taken from `this site `_. +Post Processing Filters +----------------------- + +You can apply post processing to the files in your site, in order to optimize them +or change them in arbitrary ways. For example, you may want to compress all CSS +and JS files using yui-compressor. + +To do that, you can use the provided helper adding this in your ``config.py``:: + + from nikola import filters + + FILTERS = { + ".css": [filters.yui_compressor], + ".js": [filters.yui_compressor], + } + +Where ``filters.yui_compressor`` is a helper function provided by Nikola. You can +replace that with strings describing command lines, or arbitrary python functions. + +If there's any specific thing you expect to be generally useful as a filter, contact +me and I will add it to the filters library so that more people use it. + Optimizing Your Website ----------------------- @@ -783,6 +800,9 @@ different ones, or about other webservers, please share! AddType text/css .css +#. Optionally you can greate static compressed copies and save some CPU on your server + with the GZIP_FILES option in Nikola. + #. The webassets Nikola plugin can drastically decrease the number of CSS and JS files your site fetches. #. Through the filters feature, you can run your files through arbitrary commands, so that images @@ -809,7 +829,7 @@ Once you have that, all you need to do is:: .. youtube:: 8N_tupPBtWQ Vimeo -~~~~~~~ +~~~~~ To link to a vimeo video, you need the id of the video. For example, if the URL of the video is http://www.vimeo.com/20241459 then the id is **20241459** @@ -827,6 +847,18 @@ You can override this if you wish:: height=240 width=320 +Soundcloud +~~~~~~~~~~ + +This directive lets you share music from http://soundcloud.com You first need to get the +ID for the piece, which you can find in the "share" link. For example, if the +Wordpress code starts like this:: + + [soundcloud url="http://api.soundcloud.com/tracks/78131362" + +The ID is 78131362 and you can embed the audio with this:: + + .. soundcloud:: 78131362 code-block ~~~~~~~~~~ @@ -892,22 +924,22 @@ Slideshows To create an image slideshow, you can use the ``slides`` directive. For example:: - .. slides:: + .. slides:: :preload: :play: 350 - + /galleries/demo/tesla_conducts_lg.jpg /galleries/demo/tesla_lightning2_lg.jpg /galleries/demo/tesla4_lg.jpg /galleries/demo/tesla_lightning1_lg.jpg /galleries/demo/tesla_tower1_lg.jpg -This is based on `slidejs `_ and it supports +This is based on `slidejs `_ and it supports `the options described there `_ with one minor tweak to make them fit in docutils convention: If the option takes a boolean value, you just have to add it or not. For example, to enable preloading, just use the ``:preload:`` option. -If the option takes any other kind of argument, just use it after the option, like ``play`` in the +If the option takes any other kind of argument, just use it after the option, like ``play`` in the above example. Importing Your Wordpress Site Into Nikola @@ -930,14 +962,14 @@ the following: * Will give you a url_map so you know where each old post was This is also useful for Disqus thread migration! - + * Will try to convert the content of your posts. This is *not* error free, because wordpress uses some unholy mix of HTML and strange things. Currently we are treating it as markdown, which does a reasonabe job of it. - - You will find your old posts in ``new_site/posts/post-title.wp`` in case you need to fix + + You will find your old posts in ``new_site/posts/post-title.wp`` in case you need to fix any of them. - + This feature is a work in progress, and the only way to improve it is to have it used for as many sites as possible and make it work better each time, so I am happy to get requests about it. @@ -962,6 +994,34 @@ With this command Nikola will import into the folder ``import_location``. If the folder already exists Nikola will not overwrite an existing ``conf.py``. Instead a new file with a timestamp at the end of the filename will be created. +Using Twitter Cards +------------------- + +Twitter Cards enable you to show additional information in Tweets that link +to you content. +Nikola supports `Twitter Cards `_. +They are implemented to use *Open Graph* tags whenever possible. + +.. admonition:: Important + + To use Twitter Cards you need to opt-in on Twitter. + To do so please use the form that can be found at https://dev.twitter.com/form/participate-twitter-cards + +To enable and configure your use of Twitter Cards please modify the +corresponding lines in your ``conf.py``. +An example configuration that uses the Twitter nickname of the website +and the authors Twitter user ID is found below. + +.. code-block:: Python + + TWITTER_CARD = { + 'use_twitter_cards': True, # enable Twitter Cards / Open Graph + 'site': '@website', # twitter nick for the website + # 'site:id': 123456, # Same as site, but the website's Twitter user ID instead. + # 'creator': '@username', # Username for the content creator / author. + 'creator:id': 654321, # Same as creator, but the Twitter user's ID. + } + License ------- diff --git a/docs/theming.txt b/docs/theming.txt index 33884e9..6c0c0e4 100644 --- a/docs/theming.txt +++ b/docs/theming.txt @@ -76,8 +76,8 @@ Templates --------- In templates there is a number of files whose name ends in ``.tmpl``. Those are the -theme's page templates. They are done usig the `Mako `_ -or `Jinja2 `_ template languages. If you want to do a theme, you +theme's page templates. They are done using the `Mako `_ +or `Jinja2 `_ template languages. If you want to do a theme, you should learn one first. What engine is used by the theme is declared in the ``engine`` file. The rest of this document explains Mako templates, but Jinja2 is fairly similar. diff --git a/extra_plugins/command_planetoid/__init__.py b/extra_plugins/command_planetoid/__init__.py index 7ccb19e..2428f10 100644 --- a/extra_plugins/command_planetoid/__init__.py +++ b/extra_plugins/command_planetoid/__init__.py @@ -23,7 +23,7 @@ # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import print_function +from __future__ import print_function, unicode_literals import codecs import datetime import hashlib @@ -86,7 +86,7 @@ class Planetoid(Command, Task): line = line.strip() if line.startswith("#"): continue - elif line.startswith(u'http'): + elif line.startswith('http'): feed = line elif line: name = line @@ -119,7 +119,7 @@ class Planetoid(Command, Task): elif list(f)[0].url != feed: yield { 'basename': self.name, - 'name': (u'updating_' + name).encode('utf8'), + 'name': ('updating_' + name).encode('utf8'), 'actions': ((update_feed_url, (list(f)[0], feed)), ), } @@ -224,18 +224,18 @@ class Planetoid(Command, Task): meta_path = os.path.join('posts', unique_id + '.meta') post_path = os.path.join('posts', unique_id + '.txt') with codecs.open(meta_path, 'wb+', 'utf8') as fd: - fd.write(u'%s\n' % entry.title.replace('\n', ' ')) - fd.write(u'%s\n' % unique_id) - fd.write(u'%s\n' % entry.date.strftime('%Y/%m/%d %H:%M')) - fd.write(u'\n') - fd.write(u'%s\n' % entry.link) + fd.write('%s\n' % entry.title.replace('\n', ' ')) + fd.write('%s\n' % unique_id) + fd.write('%s\n' % entry.date.strftime('%Y/%m/%d %H:%M')) + fd.write('\n') + fd.write('%s\n' % entry.link) with codecs.open(post_path, 'wb+', 'utf8') as fd: - fd.write(u'.. raw:: html\n\n') + fd.write('.. raw:: html\n\n') content = entry.content if not content: - content = u'Sin contenido' + content = 'Sin contenido' for line in content.splitlines(): - fd.write(u' %s\n' % line) + fd.write(' %s\n' % line) for entry in Entry.select().order_by(Entry.date.desc()): entry_id = gen_id(entry) diff --git a/extra_plugins/task_mustache/__init__.py b/extra_plugins/task_mustache/__init__.py index 0d0e87d..8b5ec13 100644 --- a/extra_plugins/task_mustache/__init__.py +++ b/extra_plugins/task_mustache/__init__.py @@ -73,7 +73,8 @@ class Mustache(Task): # Configuration for k, v in self.site.config.items(): - if isinstance(v, (str, unicode)): + # FIXME: not py3 ready + if isinstance(v, (str, unicode)): # NOQA data[k] = v # Tag data diff --git a/nikola/conf.py.in b/nikola/conf.py.in index 40e1996..7d75295 100644 --- a/nikola/conf.py.in +++ b/nikola/conf.py.in @@ -2,7 +2,6 @@ <%text> # -*- coding: utf-8 -*- from __future__ import unicode_literals -import os import time ############################################## @@ -13,7 +12,12 @@ import time # Data about this site BLOG_AUTHOR = "${BLOG_AUTHOR}" BLOG_TITLE = "${BLOG_TITLE}" -BLOG_URL = "${BLOG_URL}" +# This is the main URL for your site. It will be used +# in a prominent link +SITE_URL = "${SITE_URL}" +# This is the URL where nikola's output will be deployed. +# If not set, defaults to SITE_URL +# BASE_URL = "${SITE_URL} BLOG_EMAIL = "${BLOG_EMAIL}" BLOG_DESCRIPTION = "${BLOG_DESCRIPTION}" @@ -46,7 +50,7 @@ TRANSLATIONS = { "${DEFAULT_LANG}": "", # Example for another language: # "es": "./es", - } +} # Links for the sidebar / navigation bar. # You should provide a key-value pair for each used language. @@ -101,6 +105,10 @@ post_pages = ${POST_PAGES} # 'html' assumes the file is html and just copies it post_compilers = ${POST_COMPILERS} +# Create by default posts in one file format? +# Set to False for two-file posts, with separate metadata. +# ONE_FILE_POSTS = True + # Paths for different autogenerated bits. These are combined with the # translation paths. @@ -176,6 +184,11 @@ post_compilers = ${POST_COMPILERS} # ".jpg": ["jpegoptim --strip-all -m75 -v %s"], # } +# Create a gzipped copy of each generated file. Cheap server-side optimization. +# GZIP_FILES = False +# File extensions that will be compressed +# GZIP_EXTENSIONS = ('.txt', '.htm', '.html', '.css', '.js', '.json') + # ############################################################################# # Image Gallery Options # ############################################################################# @@ -198,6 +211,12 @@ post_compilers = ${POST_COMPILERS} # Name of the theme to use. Themes are located in themes/theme_name # THEME = 'site' +# If you use 'site-reveal' theme you can select several subthemes +# THEME_REVEAL_CONGIF_SUBTHEME = 'sky' # You can also use: beige/serif/simple/night/default + +# Again, if you use 'site-reveal' theme you can select several transitions between the slides +# THEME_REVEAL_CONGIF_TRANSITION = 'cube' # You can also use: page/concave/linear/none/default + # date format used to display post dates. (str used by datetime.datetime.strftime) # DATE_FORMAT = '%Y-%m-%d %H:%M' @@ -242,6 +261,25 @@ CONTENT_FOOTER = CONTENT_FOOTER.format(email=BLOG_EMAIL, # Enable comments on picture gallery pages? # COMMENTS_IN_GALLERIES = False +# Do you want a add a Mathjax config file? +# MATHJAX_CONFIG = "" + +# If you are using the compile-ipynb plugin, just add this one: +#MATHJAX_CONFIG = """ +# +#""" + # Enable Addthis social buttons? # Defaults to true # ADD_THIS_BUTTONS = True @@ -309,6 +347,39 @@ CONTENT_FOOTER = CONTENT_FOOTER.format(email=BLOG_EMAIL, # '(?P\d{4}-\d{2}-\d{2})-(?P.*)-(?P.*)\.md' # FILE_METADATA_REGEXP = None +# Nikola supports Twitter Card summaries / Open Graph. +# Twitter cards make it possible for you to attach media to Tweets +# that link to your content. +# +# IMPORTANT: +# Please note, that you need to opt-in for using Twitter Cards! +# To do this please visit https://dev.twitter.com/form/participate-twitter-cards +# +# Uncomment and modify to following lines to match your accounts. +# Specifying the id for either 'site' or 'creator' will be preferred +# over the cleartext username. Specifying an ID is not necessary. +# Displaying images is currently not supported. +# TWITTER_CARD = { +# # 'use_twitter_cards': True, # enable Twitter Cards / Open Graph +# # 'site': '@website', # twitter nick for the website +# # 'site:id': 123456, # Same as site, but the website's Twitter user ID instead. +# # 'creator': '@username', # Username for the content creator / author. +# # 'creator:id': 654321, # Same as creator, but the Twitter user's ID. +# } + + +# If you want to use formatted post time in W3C-DTF Format(ex. 2012-03-30T23:00:00+02:00), +# set timzone if you want a localized posted date. +# +# TIMEZONE = 'Europe/Zurich' + +# If webassets is installed, bundle JS and CSS to make site loading faster +# USE_BUNDLES = True + +# Plugins you don't want to use. Be careful :-) +# DISABLED_PLUGINS = ["render_galleries"] + # Put in global_context things you want available on all your templates. # It can be anything, data, functions, modules, etc. + GLOBAL_CONTEXT = {} diff --git a/nikola/console.py b/nikola/console.py deleted file mode 100644 index fae0ecd..0000000 --- a/nikola/console.py +++ /dev/null @@ -1,11 +0,0 @@ -from __future__ import print_function, unicode_literals - -from nikola import Nikola -try: - import conf - SITE = Nikola(**conf.__dict__) - SITE.scan_posts() - print("You can now access your configuration as conf and your site engine " - "as SITE") -except ImportError: - print("No configuration found.") diff --git a/nikola/data/samplesite/files/images/biohazard.png b/nikola/data/samplesite/files/images/biohazard.png new file mode 100644 index 0000000..ae4629d Binary files /dev/null and b/nikola/data/samplesite/files/images/biohazard.png differ diff --git a/nikola/data/samplesite/listings/hello.py b/nikola/data/samplesite/listings/hello.py index 695c212..885acde 100644 --- a/nikola/data/samplesite/listings/hello.py +++ b/nikola/data/samplesite/listings/hello.py @@ -4,7 +4,8 @@ import sys def hello(name='world'): - print "hello", name + greeting = "hello " + name + print(greeting) if __name__ == "__main__": hello(*sys.argv[1:]) diff --git a/nikola/data/samplesite/stories/creating-a-theme.meta b/nikola/data/samplesite/stories/creating-a-theme.meta new file mode 100644 index 0000000..fe9b69a --- /dev/null +++ b/nikola/data/samplesite/stories/creating-a-theme.meta @@ -0,0 +1,3 @@ +Creating a Theme +creating-a-theme +2012/03/13 12:00 diff --git a/nikola/data/samplesite/stories/creating-a-theme.txt b/nikola/data/samplesite/stories/creating-a-theme.txt new file mode 120000 index 0000000..108a192 --- /dev/null +++ b/nikola/data/samplesite/stories/creating-a-theme.txt @@ -0,0 +1 @@ +../../../../docs/creating-a-theme.txt \ No newline at end of file diff --git a/nikola/data/samplesite/stories/quickref.txt b/nikola/data/samplesite/stories/quickref.txt index 13ebc9b..9a06d74 100644 --- a/nikola/data/samplesite/stories/quickref.txt +++ b/nikola/data/samplesite/stories/quickref.txt @@ -55,7 +55,7 @@ <p>Links that look like "(<a href="#details">details</a>)" point into the HTML version of the full <a - href="../../ref/rst/restructuredtext.html">reStructuredText + href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html">reStructuredText specification</a> document. These are relative links; if they don't work, please use the <a href="http://docutils.sourceforge.net/docs/user/rst/quickref.html" @@ -65,7 +65,7 @@ <h2><a href="#contents" name="inline-markup" class="backref" >Inline Markup</a></h2> - <p>(<a href="../../ref/rst/restructuredtext.html#inline-markup">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup">details</a>) <p>Inline markup allows words and phrases within text to have character styles (like italics and boldface) and functionality @@ -198,7 +198,7 @@ >Escaping with Backslashes</a></h2> <p>(<a - href="../../ref/rst/restructuredtext.html#escaping-mechanism">details</a>) + href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#escaping-mechanism">details</a>) <p>reStructuredText uses backslashes ("\") to override the special meaning given to markup characters and get the literal characters @@ -246,7 +246,7 @@ <h2><a href="#contents" name="section-structure" class="backref" >Section Structure</a></h2> - <p>(<a href="../../ref/rst/restructuredtext.html#sections">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#sections">details</a>) <p><table border="1" width="100%" bgcolor="#ffffcc" cellpadding="3"> <thead> @@ -292,7 +292,7 @@ <h2><a href="#contents" name="paragraphs" class="backref" >Paragraphs</a></h2> - <p>(<a href="../../ref/rst/restructuredtext.html#paragraphs">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#paragraphs">details</a>) <p><table border="1" width="100%" bgcolor="#ffffcc" cellpadding="3"> <thead> @@ -320,7 +320,7 @@ <h2><a href="#contents" name="bullet-lists" class="backref" >Bullet Lists</a></h2> - <p>(<a href="../../ref/rst/restructuredtext.html#bullet-lists">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#bullet-lists">details</a>) <p><table border="1" width="100%" bgcolor="#ffffcc" cellpadding="3"> <thead> @@ -358,7 +358,7 @@ <h2><a href="#contents" name="enumerated-lists" class="backref" >Enumerated Lists</a></h2> - <p>(<a href="../../ref/rst/restructuredtext.html#enumerated-lists">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#enumerated-lists">details</a>) <p><table border="1" width="100%" bgcolor="#ffffcc" cellpadding="3"> <thead> @@ -396,7 +396,7 @@ <h2><a href="#contents" name="definition-lists" class="backref" >Definition Lists</a></h2> - <p>(<a href="../../ref/rst/restructuredtext.html#definition-lists">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#definition-lists">details</a>) <p><table border="1" width="100%" bgcolor="#ffffcc" cellpadding="3"> <thead> @@ -437,7 +437,7 @@ <h2><a href="#contents" name="field-lists" class="backref" >Field Lists</a></h2> - <p>(<a href="../../ref/rst/restructuredtext.html#field-lists">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#field-lists">details</a>) <p><table border="1" width="100%" bgcolor="#ffffcc" cellpadding="3"> <thead> @@ -476,7 +476,7 @@ <h2><a href="#contents" name="option-lists" class="backref" >Option Lists</a></h2> - <p>(<a href="../../ref/rst/restructuredtext.html#option-lists">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#option-lists">details</a>) <p><table border="1" width="100%" bgcolor="#ffffcc" cellpadding="3"> <thead> @@ -524,7 +524,7 @@ <h2><a href="#contents" name="literal-blocks" class="backref" >Literal Blocks</a></h2> - <p>(<a href="../../ref/rst/restructuredtext.html#literal-blocks">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#literal-blocks">details</a>) <p><table border="1" width="100%" bgcolor="#ffffcc" cellpadding="3"> <thead> @@ -613,7 +613,7 @@ <h2><a href="#contents" name="line-blocks" class="backref" >Line Blocks</a></h2> - <p>(<a href="../../ref/rst/restructuredtext.html#line-blocks">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#line-blocks">details</a>) <p><table border="1" width="100%" bgcolor="#ffffcc" cellpadding="3"> <thead> @@ -655,7 +655,7 @@ <h2><a href="#contents" name="block-quotes" class="backref" >Block Quotes</a></h2> - <p>(<a href="../../ref/rst/restructuredtext.html#block-quotes">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#block-quotes">details</a>) <p><table border="1" width="100%" bgcolor="#ffffcc" cellpadding="3"> <thead> @@ -687,7 +687,7 @@ <h2><a href="#contents" name="doctest-blocks" class="backref" >Doctest Blocks</a></h2> - <p>(<a href="../../ref/rst/restructuredtext.html#doctest-blocks">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#doctest-blocks">details</a>) <p><table border="1" width="100%" bgcolor="#ffffcc" cellpadding="3"> <thead> @@ -723,7 +723,7 @@ <h2><a href="#contents" name="tables" class="backref" >Tables</a></h2> - <p>(<a href="../../ref/rst/restructuredtext.html#tables">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#tables">details</a>) <p>There are two syntaxes for tables in reStructuredText. Grid tables are complete but cumbersome to create. Simple tables are @@ -840,7 +840,7 @@ <h2><a href="#contents" name="transitions" class="backref" >Transitions</a></h2> - <p>(<a href="../../ref/rst/restructuredtext.html#transitions">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#transitions">details</a>) <p><table border="1" width="100%" bgcolor="#ffffcc" cellpadding="3"> <thead> @@ -890,7 +890,7 @@ <h3><a href="#contents" name="footnotes" class="backref" >Footnotes</a></h3> - <p>(<a href="../../ref/rst/restructuredtext.html#footnotes">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#footnotes">details</a>) <p><table border="1" width="100%" bgcolor="#ffffcc" cellpadding="3"> <thead> @@ -983,7 +983,7 @@ <h3><a href="#contents" name="citations" class="backref" >Citations</a></h3> - <p>(<a href="../../ref/rst/restructuredtext.html#citations">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#citations">details</a>) <p><table border="1" width="100%" bgcolor="#ffffcc" cellpadding="3"> <thead> @@ -1036,7 +1036,7 @@ <h3><a href="#contents" name="hyperlink-targets" class="backref" >Hyperlink Targets</a></h3> - <p>(<a href="../../ref/rst/restructuredtext.html#hyperlink-targets">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#hyperlink-targets">details</a>) <h4><a href="#contents" name="external-hyperlink-targets" class="backref" >External Hyperlink Targets</a></h4> @@ -1081,11 +1081,11 @@ printed documents, where the link needs to be presented explicitly, for example as a footnote. You can force usage of the call-out form by using the - "<a href="../../ref/rst/directives.html#target-notes">target-notes</a>" + "<a href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#target-notes">target-notes</a>" directive. <p>reStructuredText also provides for <b>embedded URIs</b> (<a - href="../../ref/rst/restructuredtext.html#embedded-uris">details</a>), + href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#embedded-uris">details</a>), a convenience at the expense of readability. A hyperlink reference may directly embed a target URI inline, within angle brackets. The following is exactly equivalent to the example above: @@ -1149,7 +1149,7 @@ <h4><a href="#contents" name="indirect-hyperlink-targets" class="backref" >Indirect Hyperlink Targets</a></h4> - <p>(<a href="../../ref/rst/restructuredtext.html#indirect-hyperlink-targets">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#indirect-hyperlink-targets">details</a>) <p><table border="1" width="100%" bgcolor="#ffffcc" cellpadding="3"> <thead> @@ -1189,7 +1189,7 @@ <h4><a href="#contents" name="implicit-hyperlink-targets" class="backref" >Implicit Hyperlink Targets</a></h4> - <p>(<a href="../../ref/rst/restructuredtext.html#implicit-hyperlink-targets">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#implicit-hyperlink-targets">details</a>) <p>Section titles, footnotes, and citations automatically generate hyperlink targets (the title text or footnote/citation label is @@ -1217,12 +1217,12 @@ <h3><a href="#contents" name="directives" class="backref" >Directives</a></h3> - <p>(<a href="../../ref/rst/restructuredtext.html#directives">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#directives">details</a>) <p>Directives are a general-purpose extension mechanism, a way of adding support for new constructs without adding new syntax. For a description of all standard directives, see <a - href="../../ref/rst/directives.html" >reStructuredText + href="http://docutils.sourceforge.net/docs/ref/rst/directives.html" >reStructuredText Directives</a>. <p><table border="1" width="100%" bgcolor="#ffffcc" cellpadding="3"> @@ -1235,17 +1235,17 @@ <tr valign="top"> <td><samp>For instance:</samp> - <p><samp>.. image:: images/ball1.gif</samp> + <p><samp>.. image:: images/biohazard.png</samp> <td> For instance: - <p><img src="images/ball1.gif" alt="ball1"> + <p><img src="/images/biohazard.png" alt="ball1"> </table> <h3><a href="#contents" name="substitution-references-and-definitions" class="backref" >Substitution References and Definitions</a></h3> - <p>(<a href="../../ref/rst/restructuredtext.html#substitution-definitions">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#substitution-definitions">details</a>) <p>Substitutions are like inline directives, allowing graphics and arbitrary constructs within text. @@ -1268,7 +1268,7 @@ <td> - <p>The <img src="images/biohazard.png" align="bottom" alt="biohazard"> symbol + <p>The <img src="/images/biohazard.png" align="bottom" alt="biohazard"> symbol must be used on containers used to dispose of medical waste. </table> @@ -1276,7 +1276,7 @@ <h3><a href="#contents" name="comments" class="backref" >Comments</a></h3> - <p>(<a href="../../ref/rst/restructuredtext.html#comments">details</a>) + <p>(<a href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#comments">details</a>) <p>Any text which begins with an explicit markup start but doesn't use the syntax of any of the constructs above, is a comment. diff --git a/nikola/data/samplesite/stories/quickstart.txt b/nikola/data/samplesite/stories/quickstart.txt index a74d8fa..1a0f330 100644 --- a/nikola/data/samplesite/stories/quickstart.txt +++ b/nikola/data/samplesite/stories/quickstart.txt @@ -96,7 +96,7 @@ __ quickref.html#escaping middle of a word won't be recognized. See the `markup spec`__ for full details. -__ ../../ref/rst/restructuredtext.html#inline-markup +__ http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup Lists @@ -362,18 +362,18 @@ __ quickref.html#directives To include an image in your document, you use the the ``image`` directive__. For example:: - .. image:: images/biohazard.png + .. image:: /images/biohazard.png results in: -.. image:: images/biohazard.png +.. image:: /images/biohazard.png -The ``images/biohazard.png`` part indicates the filename of the image +The ``/images/biohazard.png`` part indicates the filename of the image you wish to appear in the document. There's no restriction placed on the image (format, size etc). If the image is to appear in HTML and you wish to supply additional information, you may:: - .. image:: images/biohazard.png + .. image:: /images/biohazard.png :height: 100 :width: 200 :scale: 50 @@ -381,8 +381,8 @@ you wish to supply additional information, you may:: See the full `image directive documentation`__ for more info. -__ ../../ref/rst/directives.html -__ ../../ref/rst/directives.html#images +__ http://docutils.sourceforge.net/docs/ref/rst/directives.html +__ http://docutils.sourceforge.net/docs/ref/rst/directives.html#images What Next? @@ -401,6 +401,6 @@ list. http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html. .. _reStructuredText Markup Specification: - ../../ref/rst/restructuredtext.html -.. _Docutils-users: ../mailing-lists.html#docutils-users + http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html +.. _Docutils-users: http://docutils.sourceforge.net/docs/user/mailing-lists.html#docutils-users .. _Docutils project web site: http://docutils.sourceforge.net/ diff --git a/nikola/data/themes/default/assets/css/theme.css b/nikola/data/themes/default/assets/css/theme.css index 6f3d4cb..0523ce9 100644 --- a/nikola/data/themes/default/assets/css/theme.css +++ b/nikola/data/themes/default/assets/css/theme.css @@ -49,9 +49,14 @@ div.figure > a > img { margin-right: auto; } -div.admonition, div.attention, div.caution, div.danger, div.error, div.hint, div.important, div.note, div.tip, div.warning { +div.sidebar, div.admonition, div.attention, div.caution, div.danger, div.error, div.hint, div.important, div.note, div.tip, div.warning { /* Issue 277 */ border: 1px solid #aaa; border-radius: 5px; } +blockquote p, blockquote { + font-size: 17.5px; + font-weight: 300; + line-height: 1.25; +} diff --git a/nikola/data/themes/default/assets/js/mathjax.js b/nikola/data/themes/default/assets/js/mathjax.js new file mode 100644 index 0000000..2f4e773 --- /dev/null +++ b/nikola/data/themes/default/assets/js/mathjax.js @@ -0,0 +1,12 @@ +// We wait for the onload function to load MathJax after the page is completely loaded. +// MathJax is loaded 1 unit of time after the page is ready. +// This hack prevent problems when you use social button from addthis. +// +window.onload = function () { + setTimeout(function () { + var script = document.createElement("script"); + script.type = "text/javascript"; + script.src = "https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"; + document.getElementsByTagName("body")[0].appendChild(script); + },1) +} \ No newline at end of file diff --git a/nikola/data/themes/default/bundles b/nikola/data/themes/default/bundles index 10f44e7..35af9c0 100644 --- a/nikola/data/themes/default/bundles +++ b/nikola/data/themes/default/bundles @@ -1,4 +1,4 @@ assets/css/all-nocdn.css=bootstrap.css,bootstrap-responsive.css,rst.css,code.css,colorbox.css,slides.css,theme.css,custom.css assets/css/all.css=rst.css,code.css,colorbox.css,slides.css,theme.css,custom.css -assets/js/all-nocdn.js=bootstrap.min.js,jquery-1.7.2.min.js,jquery.colorbox-min.js,slides.min.jquery.js +assets/js/all-nocdn.js=jquery-1.7.2.min.js,bootstrap.min.js,jquery.colorbox-min.js,slides.min.jquery.js assets/js/all.js=jquery.colorbox-min.js,slides.min.jquery.js diff --git a/nikola/data/themes/default/templates/base.tmpl b/nikola/data/themes/default/templates/base.tmpl index 7af8497..c0935a2 100644 --- a/nikola/data/themes/default/templates/base.tmpl +++ b/nikola/data/themes/default/templates/base.tmpl @@ -48,6 +48,10 @@ </ul> <!--End of sidebar content--> </div> + </div> + </div> + </div> +</div> ${analytics} ${late_load_js()} <script type="text/javascript">jQuery("a.image-reference").colorbox({rel:"gal",maxWidth:"80%",maxHeight:"80%",scalePhotos:true});</script> diff --git a/nikola/data/themes/default/templates/base_helper.tmpl b/nikola/data/themes/default/templates/base_helper.tmpl index 51969c9..eb22905 100644 --- a/nikola/data/themes/default/templates/base_helper.tmpl +++ b/nikola/data/themes/default/templates/base_helper.tmpl @@ -4,7 +4,7 @@ <meta name="description" content="${description}" > <meta name="author" content="${blog_author}"> <title>${title} | ${blog_title} - + ${mathjax_config} %if use_bundles: %if use_cdn: @@ -28,7 +28,6 @@ %endif %endif - @@ -36,7 +35,7 @@ ${rss_link} %else: %for language in translations: - + %endfor %endif %if favicons: @@ -73,10 +72,10 @@
Share -
  • -
  • -
  • -
  • +
    • +
    • +
    • +
diff --git a/nikola/data/themes/default/templates/gallery.tmpl b/nikola/data/themes/default/templates/gallery.tmpl index 3186cc8..09c25cc 100644 --- a/nikola/data/themes/default/templates/gallery.tmpl +++ b/nikola/data/themes/default/templates/gallery.tmpl @@ -6,7 +6,7 @@ <%block name="content"> %if text: @@ -16,13 +16,13 @@ %endif
    %for image in images:
  • -
  • + %endfor
%if enable_comments: diff --git a/nikola/data/themes/default/templates/index.tmpl b/nikola/data/themes/default/templates/index.tmpl index 1a436e2..4f66867 100644 --- a/nikola/data/themes/default/templates/index.tmpl +++ b/nikola/data/themes/default/templates/index.tmpl @@ -7,7 +7,7 @@

${post.title(lang)}    - ${messages[lang]["Posted"]}: ${post.date.strftime(date_format)} + ${messages[lang]["Posted"]}:


${post.text(lang, index_teasers)} @@ -16,4 +16,5 @@ % endfor ${helper.html_pager()} ${disqus.html_disqus_script()} + ${helper.mathjax_script(post)} diff --git a/nikola/data/themes/default/templates/index_helper.tmpl b/nikola/data/themes/default/templates/index_helper.tmpl index 114a730..151b4d2 100644 --- a/nikola/data/themes/default/templates/index_helper.tmpl +++ b/nikola/data/themes/default/templates/index_helper.tmpl @@ -5,13 +5,17 @@ %if prevlink: %endif %if nextlink: %endif
+ +<%def name="mathjax_script(post)"> + %if any(post.is_mathjax for post in posts): + + %endif + diff --git a/nikola/data/themes/default/templates/listing.tmpl b/nikola/data/themes/default/templates/listing.tmpl index 596a704..f279af0 100644 --- a/nikola/data/themes/default/templates/listing.tmpl +++ b/nikola/data/themes/default/templates/listing.tmpl @@ -3,8 +3,18 @@ <%block name="content"> -${code} +
    +% for name in folders: +
  • ${name} +% endfor +% for name in files: +
  • ${name} +% endfor +
+% if code: + ${code} +% endif diff --git a/nikola/data/themes/default/templates/post.tmpl b/nikola/data/themes/default/templates/post.tmpl index 672d4f6..22d8a58 100644 --- a/nikola/data/themes/default/templates/post.tmpl +++ b/nikola/data/themes/default/templates/post.tmpl @@ -2,20 +2,28 @@ <%namespace name="helper" file="post_helper.tmpl"/> <%namespace name="disqus" file="disqus_helper.tmpl"/> <%inherit file="base.tmpl"/> +<%block name="extra_head"> +${helper.twitter_card_information(post)} + <%block name="content">
${helper.html_title()}
- ${messages[lang]["Posted"]}: ${post.date.strftime(date_format)} + ${messages[lang]["Posted"]}: ${helper.html_translations(post)} -   |   - ${messages[lang]["Source"]} ${helper.html_tags(post)}
${post.text(lang)} ${helper.html_pager(post)} ${disqus.html_disqus(post.permalink(absolute=True), post.title(lang), post.base_path)} + ${helper.mathjax_script(post)}
+ +<%block name="sourcelink"> +
  • + ${messages[lang]["Source"]} +
  • + diff --git a/nikola/data/themes/default/templates/post_helper.tmpl b/nikola/data/themes/default/templates/post_helper.tmpl index ab08359..911a831 100644 --- a/nikola/data/themes/default/templates/post_helper.tmpl +++ b/nikola/data/themes/default/templates/post_helper.tmpl @@ -33,12 +33,39 @@ %if post.prev_post: %endif %if post.next_post: %endif + +<%def name="twitter_card_information(post)"> + %if twitter_card and twitter_card['use_twitter_cards']: + + + %if 'site:id' in twitter_card: + + %elif 'site' in twitter_card: + + %endif + %if 'creator:id' in twitter_card: + + %elif 'creator' in twitter_card: + + %endif + + %if post.description(lang): + + %else: + + %endif + %endif + + +<%def name="mathjax_script(post)"> + %if post.is_mathjax: + + %endif + diff --git a/nikola/data/themes/jinja-default/templates/base.tmpl b/nikola/data/themes/jinja-default/templates/base.tmpl index 32e5d48..97cddff 100644 --- a/nikola/data/themes/jinja-default/templates/base.tmpl +++ b/nikola/data/themes/jinja-default/templates/base.tmpl @@ -93,15 +93,19 @@
    Share -
    • -
    • -
    • -
    • +
      • +
      • +
      • +
    {% endif %} + + + + {{analytics}} {% if use_bundles %} diff --git a/nikola/data/themes/jinja-default/templates/gallery.tmpl b/nikola/data/themes/jinja-default/templates/gallery.tmpl index 34ff439..9b16df6 100644 --- a/nikola/data/themes/jinja-default/templates/gallery.tmpl +++ b/nikola/data/themes/jinja-default/templates/gallery.tmpl @@ -4,7 +4,7 @@ {% block content %} {% if text %} @@ -14,13 +14,13 @@ {% endif %}
      {% for image in images %} -
    • - +
    • + {% endfor %}
    {%if enable_comments %} diff --git a/nikola/data/themes/jinja-default/templates/index.tmpl b/nikola/data/themes/jinja-default/templates/index.tmpl index ad54c19..ab0392c 100644 --- a/nikola/data/themes/jinja-default/templates/index.tmpl +++ b/nikola/data/themes/jinja-default/templates/index.tmpl @@ -19,12 +19,10 @@ {%if prevlink %} {% endif %} {% if nextlink %} + {{messages[lang]["Older posts"]}} → {% endif %} diff --git a/nikola/data/themes/jinja-default/templates/listing.tmpl b/nikola/data/themes/jinja-default/templates/listing.tmpl index 8310635..493624a 100644 --- a/nikola/data/themes/jinja-default/templates/listing.tmpl +++ b/nikola/data/themes/jinja-default/templates/listing.tmpl @@ -2,7 +2,7 @@ {% block content %} {{code}} diff --git a/nikola/data/themes/jinja-default/templates/post.tmpl b/nikola/data/themes/jinja-default/templates/post.tmpl index 2a356c5..d14e973 100644 --- a/nikola/data/themes/jinja-default/templates/post.tmpl +++ b/nikola/data/themes/jinja-default/templates/post.tmpl @@ -32,12 +32,10 @@ {%if post.prev_post %} {% endif %} {%if post.next_post %} {% endif %} {% if disqus_forum %} diff --git a/nikola/data/themes/site/README b/nikola/data/themes/site/README index 6cbc7dd..c89543c 100644 --- a/nikola/data/themes/site/README +++ b/nikola/data/themes/site/README @@ -29,4 +29,4 @@ default duckduckgo search form: - """ % BLOG_URL + """ % SITE_URL diff --git a/nikola/data/themes/site/assets/css/theme.css b/nikola/data/themes/site/assets/css/theme.css index 0183c69..aa0ee4a 100644 --- a/nikola/data/themes/site/assets/css/theme.css +++ b/nikola/data/themes/site/assets/css/theme.css @@ -52,8 +52,15 @@ div.figure > a > img { margin-right: auto; } -div.admonition, div.attention, div.caution, div.danger, div.error, div.hint, div.important, div.note, div.tip, div.warning { +div.sidebar, div.admonition, div.attention, div.caution, div.danger, div.error, div.hint, div.important, div.note, div.tip, div.warning { /* Issue 277 */ border: 1px solid #aaa; border-radius: 5px; } + +blockquote p, blockquote { + font-size: 17.5px; + font-weight: 300; + line-height: 1.25; +} + diff --git a/nikola/data/themes/site/templates/post.tmpl b/nikola/data/themes/site/templates/post.tmpl deleted file mode 100644 index 785385f..0000000 --- a/nikola/data/themes/site/templates/post.tmpl +++ /dev/null @@ -1,25 +0,0 @@ -## -*- coding: utf-8 -*- -<%namespace name="helper" file="post_helper.tmpl"/> -<%namespace name="disqus" file="disqus_helper.tmpl"/> -<%inherit file="base.tmpl"/> -<%block name="content"> -
    - ${helper.html_title()} -
    - - ${messages[lang]["Posted"]}: ${post.date.strftime(date_format)} - ${helper.html_translations(post)} - ${helper.html_tags(post)} - -
    - ${post.text(lang)} - ${helper.html_pager(post)} - ${disqus.html_disqus(post.permalink(absolute=True), post.title(lang), post.base_path)} -
    - - -<%block name="sourcelink"> -
  • - ${messages[lang]["Source"]} -
  • - diff --git a/nikola/filters.py b/nikola/filters.py index 4a63cb4..a3bff81 100644 --- a/nikola/filters.py +++ b/nikola/filters.py @@ -80,9 +80,10 @@ def tidy(inplace): # Tidy will give error exits, that we will ignore. output = subprocess.check_output("tidy -m -w 90 --indent no --quote-marks" - "no --keep-time yes --tidy-mark no '%s';" - "exit 0" % inplace, - stderr=subprocess.STDOUT, shell=True) + "no --keep-time yes --tidy-mark no " + "--force-output yes '{0}'; exit 0".format( + inplace), stderr=subprocess.STDOUT, + shell=True) for line in output.split("\n"): if "Warning:" in line: @@ -101,7 +102,15 @@ def tidy(inplace): elif ' lacks "summary" attribute' in line: # Happens for tables, TODO: Check this is normal. continue + elif 'proprietary attribute "data-toggle"' in line or \ + 'proprietary attribute "data-target"': + # Some of our own tricks + continue else: assert False, (inplace, line) elif "Error:" in line: - assert False, line + if '