Skip to content

Commit

Permalink
Merge pull request #2838 from getnikola/v8-cleanup
Browse files Browse the repository at this point in the history
v8: cleanup and a few features
  • Loading branch information
Kwpolska committed Jun 16, 2017
2 parents a6164a4 + d71da82 commit 4f2574c
Show file tree
Hide file tree
Showing 162 changed files with 276 additions and 1,350 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -11,7 +11,6 @@ addons:
- language-pack-en-base
- language-pack-pl-base
python:
- '2.7'
- '3.3'
- '3.4'
- '3.5'
Expand Down
22 changes: 22 additions & 0 deletions CHANGES.txt
@@ -1,3 +1,25 @@
New in master
=============

Features
--------

* Use ``PRETTY_URLS`` by default on all sites (Issue #1838)

Bugfixes
--------
* Use Jupyter name more consistently in docs
* Support CODE_COLOR_SCHEME in Jupyter notebooks (Issue #2093)


Removed features
----------------
* Drop Python 2 support
* Remove ``nikola install_theme`` — use ``nikola theme`` instead
* Drop insecure post encryption feature
* Stop supporting all deprecated config options
* Drop annotations support (annotateit.org closed down in March 2017)

New in v7.8.8
=============

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -43,7 +43,7 @@ It has many features, but here are some of the nicer ones:
* Syntax highlighting for almost any programming language or markup
* Multilingual sites, `translated to 50 languages.`__
* Doesn't reinvent wheels, leverages existing tools.
* Python 2.7, 3.3, 3.4, 3.5 and 3.6 compatible.
* Python 3.3+ compatible.

.. _Nikola Handbook: https://getnikola.com/handbook.html#why-static
__ https://users.getnikola.com/
Expand Down
1 change: 0 additions & 1 deletion appveyor.yml
Expand Up @@ -2,7 +2,6 @@
build: false
environment:
matrix:
- PYTHON: "C:/Python27"
- PYTHON: "C:/Python36"
init:
- "ECHO %PYTHON%"
Expand Down
23 changes: 12 additions & 11 deletions docs/creating-a-theme.txt
Expand Up @@ -17,7 +17,7 @@ create themes. Since I **suck** at designing websites, I asked for opinions on t
and got some feedback. Since this is **Not So Hard™**, I will try to make time to port a few
and see what happens.

If you are looking for a reference, check out `Theming reference <theming.html>`_ and `Template variables <https://getnikola.com/template-variables.html>`_.
If you are looking for a reference, check out :doc:`Theming reference <theming>` and `Template variables <https://getnikola.com/template-variables.html>`_.

Today’s theme is `Lanyon <https://github.com/poole/lanyon>`__ which is written by `@mdo <https://twitter.com/mdo>`__
and released under a MIT license, which is liberal enough.
Expand Down Expand Up @@ -176,7 +176,7 @@ see something fairly similar:
<meta name="viewport" content="width=device-width">
<title>My Nikola Site | My Nikola Site</title>

<link href="assets/css/rst.css" rel="stylesheet" type="text/css">
<link href="assets/css/html4css1.css" rel="stylesheet" type="text/css">
<link href="assets/css/code.css" rel="stylesheet" type="text/css">
<link href="assets/css/theme.css" rel="stylesheet" type="text/css">

Expand All @@ -199,10 +199,11 @@ in a particular way, using a setting called ``CODE_COLOR_SCHEME`` where you can
what color scheme the syntax highlighter uses. You can use your own ``assets/css/code.css`` if you
don’t like the provided ones.

Nikola **requires** ``assets/css/rst.css`` and ``assets/css/code.css`` to function properly.
We will also add themes for IPython Notebook (``assets/css/ipython.min.css``
Nikola **requires** ``assets/css/html4css1.css`` and ``assets/css/code.css`` to function properly.
We will also add themes for Jupyter (``assets/css/ipython.min.css``
and ``assets/css/nikola_ipython.css``) into the template; note that they are
activated only if you configured your ``POSTS``/``PAGES`` with ipynb support.
There’s also ``assets/css/nikola_rst.css``, which adds Bootstrap 3-style reST notes etc.

But how do I tell **our** lanyon theme to use those CSS files instead of whatever it’s using now?
By giving our theme its own base_helper.tmpl.
Expand All @@ -226,7 +227,8 @@ The part we want to change is this:
<link href="/assets/css/all-nocdn.css" rel="stylesheet" type="text/css">
%endif
%else:
<link href="/assets/css/rst.css" rel="stylesheet" type="text/css">
<link href="/assets/css/html4css1.css" rel="stylesheet" type="text/css">
<link href="/assets/css/nikola_rst.css" rel="stylesheet" type="text/css">
<link href="/assets/css/code.css" rel="stylesheet" type="text/css">
<link href="/assets/css/theme.css" rel="stylesheet" type="text/css">
%if has_custom_css:
Expand All @@ -247,7 +249,8 @@ And we will change it so it uses the lanyon styles instead of theme.css (again,
%if use_bundles:
<link href="/assets/css/all.css" rel="stylesheet" type="text/css">
%else:
<link href="/assets/css/rst.css" rel="stylesheet" type="text/css">
<link href="/assets/css/html4css1.css" rel="stylesheet" type="text/css">
<link href="/assets/css/nikola_rst.css" rel="stylesheet" type="text/css">
<link href="/assets/css/poole.css" rel="stylesheet" type="text/css">
<link href="/assets/css/lanyon.css" rel="stylesheet" type="text/css">
<link href="/assets/css/code.css" rel="stylesheet" type="text/css">
Expand Down Expand Up @@ -326,7 +329,6 @@ all the interesting stuff:
<%namespace name="base" file="base_helper.tmpl" import="*"/>
<%namespace name="header" file="base_header.tmpl" import="*"/>
<%namespace name="footer" file="base_footer.tmpl" import="*"/>
<%namespace name="annotations" file="annotation_helper.tmpl"/>
${set_locale(lang)}
${base.html_headstart()}
<%block name="extra_head">
Expand Down Expand Up @@ -362,7 +364,6 @@ So, first, lets change that base template to be more lanyon-like:
<%namespace name="base" file="base_helper.tmpl" import="*"/>
<%namespace name="header" file="base_header.tmpl" import="*"/>
<%namespace name="footer" file="base_footer.tmpl" import="*"/>
<%namespace name="annotations" file="annotation_helper.tmpl"/>
${set_locale(lang)}
${base.html_headstart()}
<%block name="extra_head">
Expand Down Expand Up @@ -401,7 +402,7 @@ So, first, lets change that base template to be more lanyon-like:
And that’s after I exposed the sidebar by clicking on an invisible widget!

One problem, which causes that yellow color in the sidebar is a CSS conflict.
We are loading ``rst.css`` which specifies
We are loading ``html4css1.css`` which specifies
the background color of ``div.sidebar`` which is more specific than
``lanyon.css``, which specifies for ``.sidebar`` alone.

Expand Down Expand Up @@ -505,7 +506,7 @@ and at the bottom a label for the sidebar toggle. Easy to do in ``base.tmpl``

Getting there!

The sidebar looks bad because of yet more CSS conflicts with ``rst.css``. By
The sidebar looks bad because of yet more CSS conflicts with ``html4css1.css``. By
adding some extra styling in ``lanyon.css``, it will look better.

.. code:: css
Expand Down Expand Up @@ -815,7 +816,7 @@ which makes sites load faster. To do that, your theme needs a ``bundles`` file w

For the Lanyon theme, it should be like this::

assets/css/all.css=rst.css,code.css,poole.css,lanyon.css,custom.css
assets/css/all.css=html4css1.css,nikola_rst.css,code.css,poole.css,lanyon.css,custom.css

**Note:** Some themes also support the ``USE_CDN`` option meaning that in some cases it will load one bundle with all CSS and in other will load some CSS files
from a CDN and others from a bundle. This is complicated and probably not worth the effort.
Expand Down
41 changes: 13 additions & 28 deletions docs/manual.txt
Expand Up @@ -78,7 +78,7 @@ Nikola can't do:
* Twitter
* Facebook
* An Issue tracker
* Anything with forms, really (except for `comments <#comments-and-annotations>`_!)
* Anything with forms, really (except for `comments`_!)

Keep in mind that "static" doesn't mean **boring**. You can have animations, slides
or whatever fancy CSS3/HTML5 thingie you like. It only means all that HTML is
Expand Down Expand Up @@ -136,7 +136,7 @@ Obsolescence
You may say those are long term issues, or that they won't matter for years. Well,
I believe things should work forever, or as close to it as we can make them.
Nikola's static output and its input files will work as long as you can install
a Python 2.7/3.3 or newer under Linux, Windows, or OS X and can find a server
Python 3.3 or newer under Linux, Windows, or OS X and can find a server
that sends files over HTTP. That's probably 10 or 15 years at least.

Also, static sites are easily handled by the Internet Archive.
Expand Down Expand Up @@ -227,7 +227,7 @@ easier to keep it in a single location.
The contents of your post have to be written (by default) in `reStructuredText <http://docutils.sf.net>`__
but you can use a lot of different markups using the ``-f`` option.

Currently, Nikola supports reStructuredText, Markdown, Jupyter (IPython) Notebooks, HTML as input,
Currently, Nikola supports reStructuredText, Markdown, Jupyter Notebooks, HTML as input,
can also use Pandoc for conversion, and has support for BBCode, CreoleWiki, txt2tags, Textile
and more via plugins — for more details, read the `input format documentation
<#multiple-input-formats>`__.
Expand Down Expand Up @@ -326,9 +326,6 @@ author
Author of the post, will be used in the RSS feed and possibly in the post
display (theme-dependent)

annotations / noannotations
Override the value of the ``ANNOTATIONS`` option for this specific post or page.

enclosure
Add an enclosure to this post when it's used in RSS. See `more information about enclosures <http://en.wikipedia.org/wiki/RSS_enclosure>`__

Expand Down Expand Up @@ -1035,7 +1032,7 @@ Nikola supports multiple input formats. Out of the box, we have compilers avail

* reStructuredText (default and pre-configured)
* `Markdown`_
* `Jupyter/IPython Notebook`_
* `Jupyter Notebook`_
* `HTML`_
* `PHP`_
* anything `Pandoc`_ supports (including Textile, DocBook, LaTeX, MediaWiki,
Expand Down Expand Up @@ -1093,12 +1090,12 @@ config option:
Nikola comes with some Markdown Extensions built-in and enabled by default,
namely a gist directive, a podcast directive, and ``~~strikethrough~~`` support.

Jupyter/IPython Notebook
````````````````````````
Jupyter Notebook
````````````````

To use Jupyter Notebooks (previously known as IPython Notebooks) as posts/pages,
make sure ``ipynb`` is in your ``COMPILERS`` and that the ``.ipynb`` extension
is defined in ``POSTS`` and ``PAGES``.
To use Jupyter Notebooks as posts/pages, make sure ``ipynb`` is in your
``COMPILERS`` and that the ``.ipynb`` extension is defined in ``POSTS`` and
``PAGES``.

The ``-f`` argument to ``new_post`` should be used in the ``ipynb@KERNEL`` format.
It defaults to Python in the version used by Nikola if not specified.
Expand Down Expand Up @@ -1411,7 +1408,7 @@ CSS tweaking
for minimal disruption of the provided CSS files.

If you feel tempted to touch other files in assets, you probably will be better off
with a `custom theme <theming.html>`__.
with a :doc:`custom theme <theming>`.

If you want to use LESS_ or Sass_ for your custom CSS, or the theme you use
contains LESS or Sass code that you want to override, you will need to install
Expand All @@ -1425,7 +1422,7 @@ CSS tweaking

Template tweaking and creating themes
If you really want to change the pages radically, you will want to do a
`custom theme <theming.html>`__.
:doc:`custom theme <theming>`.

Navigation Links
The ``NAVIGATION_LINKS`` option lets you define what links go in a sidebar or menu
Expand Down Expand Up @@ -1718,8 +1715,8 @@ GitLab also offers rebuild automation if you want to use Nikola with GitLab
Pages. Check out the example `Nikola site on GitLab
<https://gitlab.com/pages/nikola>`_.

Comments and Annotations
------------------------
Comments
--------

While Nikola creates static sites, there is a minimum level of user interaction you
are probably expecting: comments.
Expand Down Expand Up @@ -1799,18 +1796,6 @@ You can disable comments for a post by adding a "nocomments" metadata field to i
You need jQuery, but not because Facebook wants it (see Issue
#639).

An alternative or complement to comments are annotations. Nikola integrates
the annotation service provided by `AnnotateIt. <http://annotateit.org/>`_
To use it, set the ``ANNOTATIONS`` option to True. This is specially useful
if you want feedback on specific parts of your writing.

You can enable or disable annotations for specific posts or pages using the
``annotations`` and ``noannotations`` metadata.

Annotations require jQuery and are therefore not supported in the base theme.
You can check bootstrap theme's ``base.html`` for details on how to handle them in
custom themes.

Images and Galleries
--------------------

Expand Down
3 changes: 1 addition & 2 deletions docs/template-variables.rst
Expand Up @@ -39,7 +39,6 @@ Name Type Descript
================================== ================================== ================================================================================
``_link`` function ``Nikola.link`` function
``abs_link`` function ``Nikola.abs_link`` function
``annotations`` bool ``ANNOTATIONS`` setting
``author_pages_generated`` bool False
``blog_author`` TranslatableSetting<str> ``BLOG_AUTHOR`` setting
``blog_description`` TranslatableSetting<str> ``BLOG_DESCRIPTION`` setting
Expand Down Expand Up @@ -78,7 +77,7 @@ Name Type Descript
``meta_generator_tag`` bool ``META_GENERATOR_TAG`` setting
``momentjs_locales`` defaultdict<str, str> dictionary of available Moment.js locales
``navigation_links`` TranslatableSetting ``NAVIGATION_LINKS`` setting
``needs_ipython_css`` bool whether or not IPython CSS is needed by this site
``needs_ipython_css`` bool whether or not Jupyter CSS is needed by this site
``posts_sections`` bool ``POSTS_SECTIONS`` setting
``posts_section_are_indexes`` bool ``POSTS_SECTIONS_ARE_INDEXES`` setting
``posts_sections_are_indexes`` bool ``POSTS_SECTIONS_ARE_INDEXES`` setting
Expand Down
7 changes: 2 additions & 5 deletions docs/theming.txt
Expand Up @@ -19,7 +19,7 @@ Theming Nikola
.. class:: lead

This document is a reference about themes. If you want a tutorial, please read
`Creating a Theme <creating-a-theme.html>`_. If you’re looking for a ready-made
:doc:`Creating a Theme <creating-a-theme>`. If you’re looking for a ready-made
theme for your site, check out the `Themes Index <https://themes.getnikola.com/>`_.

The Structure
Expand Down Expand Up @@ -78,7 +78,7 @@ bundles

.. code:: text

assets/css/all.css=bootstrap.css,rst.css,code.css,colorbox.css,custom.css
assets/css/all.css=bootstrap.css,html4css1.css,nikola_rst.css,code.css,colorbox.css,custom.css

This creates a file called "assets/css/all.css" in your output that is the
combination of all the other file paths, relative to the output file.
Expand Down Expand Up @@ -195,9 +195,6 @@ These are the templates that come with the included themes:
Template used to render the multipost indexes. The posts are in a ``posts`` variable.
Some functionality is in the ``index_helper.tmpl`` helper template.

``annotation_helper.tmpl`` (internal)
Code for the optional annotations feature.

``archive_navigation_helper.tmpl``
Code that implements archive navigation (previous/up/next). Included by
archive templates.
Expand Down
7 changes: 5 additions & 2 deletions nikola/__init__.py
Expand Up @@ -26,11 +26,14 @@

"""Nikola -- a modular, fast, simple, static website generator."""

from __future__ import absolute_import
import os
import sys

__version__ = '7.8.8'
__version__ = '8.0.0.dev0'
DEBUG = bool(os.getenv('NIKOLA_DEBUG'))

if sys.version_info[0] == 2:
raise Exception("Nikola does not support Python 2.")

from .nikola import Nikola # NOQA
from . import plugins # NOQA
18 changes: 4 additions & 14 deletions nikola/__main__.py
Expand Up @@ -26,8 +26,6 @@

"""The main function of Nikola."""

from __future__ import print_function, unicode_literals

import os
import shutil
import sys
Expand All @@ -51,18 +49,15 @@
from .plugin_categories import Command
from .utils import (LOGGER, STDERR_HANDLER, STRICT_HANDLER,
ColorfulStderrHandler, get_root_dir, req_missing,
sys_decode, sys_encode)
sys_decode)

try:
import readline # NOQA
except ImportError:
pass # This is only so raw_input/input does nicer things if it's available


if sys.version_info[0] == 3:
import importlib.machinery
else:
import imp
import importlib.machinery

config = {}

Expand All @@ -85,14 +80,12 @@ def main(args=None):
args = [sys_decode(arg) for arg in args]

conf_filename = 'conf.py'
conf_filename_bytes = b'conf.py'
conf_filename_changed = False
for index, arg in enumerate(args):
if arg[:7] == '--conf=':
del args[index]
del oargs[index]
conf_filename = arg[7:]
conf_filename_bytes = sys_encode(arg[7:])
conf_filename_changed = True
break

Expand Down Expand Up @@ -129,11 +122,8 @@ def main(args=None):

sys.path.append('')
try:
if sys.version_info[0] == 3:
loader = importlib.machinery.SourceFileLoader("conf", conf_filename)
conf = loader.load_module()
else:
conf = imp.load_source("conf", conf_filename_bytes)
loader = importlib.machinery.SourceFileLoader("conf", conf_filename)
conf = loader.load_module()
config = conf.__dict__
except Exception:
if os.path.exists(conf_filename):
Expand Down

0 comments on commit 4f2574c

Please sign in to comment.