Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' into persistent-state
  • Loading branch information
ralsina committed Jan 25, 2016
2 parents f5aefdd + 9b441bd commit 27d24b6
Show file tree
Hide file tree
Showing 21 changed files with 71 additions and 34 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Expand Up @@ -15,6 +15,9 @@ Features
Bugfixes
--------

* Honor ``MATHJAX_CONFIG``
* Display tags and archives in a unified format, with the date on the
left, instead of a misplaced dash in tags (Issue #2212)
* Decide is_mathjax based on current language tags (Issue #2205)
* Don't duplicate images in flowr when resizing page (Issue #2202)

Expand Down
1 change: 1 addition & 0 deletions nikola/data/shortcodes/jinja/raw.tmpl
@@ -0,0 +1 @@
{{ data }}
2 changes: 1 addition & 1 deletion nikola/data/themes/base-jinja/templates/author.tmpl
Expand Up @@ -35,7 +35,7 @@
{% if posts %}
<ul class="postlist">
{% for post in posts %}
<li><a href="{{ post.permalink() }}" class="listtitle">{{ post.title()|e }}</a><time class="listdate" datetime="{{ post.formatted_date('webiso') }}" title="{{ post.formatted_date(date_format)|e }}">{{ post.formatted_date(date_format)|e }}</time></li>
<li><time class="listdate" datetime="{{ post.formatted_date('webiso') }}" title="{{ post.formatted_date(date_format)|e }}">{{ post.formatted_date(date_format)|e }}</time> <a href="{{ post.permalink() }}" class="listtitle">{{ post.title()|e }}</a></li>
{% endfor %}
</ul>
{% endif %}
Expand Down
4 changes: 4 additions & 0 deletions nikola/data/themes/base-jinja/templates/index_helper.tmpl
Expand Up @@ -28,9 +28,13 @@
</script>
{% else %}
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>
{% if mathjax_config %}
{{ mathjax_config }}
{% else %}
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$latex ','$'], ['\\(','\\)']]}});
</script>
{% endif %}
{% endif %}
{% endif %}
{% endmacro %}
2 changes: 1 addition & 1 deletion nikola/data/themes/base-jinja/templates/list_post.tmpl
Expand Up @@ -9,7 +9,7 @@
{% if posts %}
<ul class="postlist">
{% for post in posts %}
<li><a href="{{ post.permalink() }}" class="listtitle">{{ post.title()|e }}</a> <time class="listdate" datetime="{{ post.formatted_date('webiso') }}" title="{{ post.formatted_date(date_format)|e }}">{{ post.formatted_date(date_format)|e }}</time></li>
<li><time class="listdate" datetime="{{ post.formatted_date('webiso') }}" title="{{ post.formatted_date(date_format)|e }}">{{ post.formatted_date(date_format)|e }}</time> <a href="{{ post.permalink() }}" class="listtitle">{{ post.title()|e }}</a></li>
{% endfor %}
</ul>
{% else %}
Expand Down
4 changes: 4 additions & 0 deletions nikola/data/themes/base-jinja/templates/post_helper.tmpl
Expand Up @@ -94,9 +94,13 @@
</script>
{% else %}
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>
{% if mathjax_config %}
{{ mathjax_config }}
{% else %}
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$latex ','$'], ['\\(','\\)']]}});
</script>
{% endif %}
{% endif %}
{% endif %}
{% endmacro %}
2 changes: 1 addition & 1 deletion nikola/data/themes/base-jinja/templates/tag.tmpl
Expand Up @@ -43,7 +43,7 @@
{% if posts %}
<ul class="postlist">
{% for post in posts %}
<li><time class="listdate" datetime="{{ post.formatted_date('webiso') }}" title="{{ post.formatted_date(date_format)|e }}">{{ post.formatted_date(date_format)|e }}</time><a href="{{ post.permalink() }}" class="listtitle">{{ post.title()|e }}<a></li>
<li><time class="listdate" datetime="{{ post.formatted_date('webiso') }}" title="{{ post.formatted_date(date_format)|e }}">{{ post.formatted_date(date_format)|e }}</time> <a href="{{ post.permalink() }}" class="listtitle">{{ post.title()|e }}<a></li>
{% endfor %}
</ul>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/base/assets/css/theme.css
Expand Up @@ -120,7 +120,7 @@ body {
}
.metadata p:before,
.postpromonav .tags li:before,
.postlist .listdate:before {
.postlist .listdate:after {
content: " — ";
}
.postlist li {
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/base/templates/author.tmpl
Expand Up @@ -35,7 +35,7 @@
%if posts:
<ul class="postlist">
% for post in posts:
<li><a href="${post.permalink()}" class="listtitle">${post.title()|h}</a><time class="listdate" datetime="${post.formatted_date('webiso')}" title="${post.formatted_date(date_format)|h}">${post.formatted_date(date_format)|h}</time></li>
<li><time class="listdate" datetime="${post.formatted_date('webiso')}" title="${post.formatted_date(date_format)|h}">${post.formatted_date(date_format)|h}</time> <a href="${post.permalink()}" class="listtitle">${post.title()|h}</a></li>
% endfor
</ul>
%endif
Expand Down
4 changes: 4 additions & 0 deletions nikola/data/themes/base/templates/index_helper.tmpl
Expand Up @@ -28,9 +28,13 @@
</script>
%else:
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>
% if mathjax_config:
${mathjax_config}
% else:
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$latex ','$'], ['\\(','\\)']]}});
</script>
% endif
%endif
%endif
</%def>
2 changes: 1 addition & 1 deletion nikola/data/themes/base/templates/list_post.tmpl
Expand Up @@ -9,7 +9,7 @@
%if posts:
<ul class="postlist">
% for post in posts:
<li><a href="${post.permalink()}" class="listtitle">${post.title()|h}</a> <time class="listdate" datetime="${post.formatted_date('webiso')}" title="${post.formatted_date(date_format)|h}">${post.formatted_date(date_format)|h}</time></li>
<li><time class="listdate" datetime="${post.formatted_date('webiso')}" title="${post.formatted_date(date_format)|h}">${post.formatted_date(date_format)|h}</time> <a href="${post.permalink()}" class="listtitle">${post.title()|h}</a></li>
% endfor
</ul>
%else:
Expand Down
4 changes: 4 additions & 0 deletions nikola/data/themes/base/templates/post_helper.tmpl
Expand Up @@ -94,9 +94,13 @@
</script>
%else:
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>
% if mathjax_config:
${mathjax_config}
% else:
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$latex ','$'], ['\\(','\\)']]}});
</script>
% endif
%endif
%endif
</%def>
2 changes: 1 addition & 1 deletion nikola/data/themes/base/templates/tag.tmpl
Expand Up @@ -43,7 +43,7 @@
%if posts:
<ul class="postlist">
% for post in posts:
<li><time class="listdate" datetime="${post.formatted_date('webiso')}" title="${post.formatted_date(date_format)|h}">${post.formatted_date(date_format)|h}</time><a href="${post.permalink()}" class="listtitle">${post.title()|h}<a></li>
<li><time class="listdate" datetime="${post.formatted_date('webiso')}" title="${post.formatted_date(date_format)|h}">${post.formatted_date(date_format)|h}</time> <a href="${post.permalink()}" class="listtitle">${post.title()|h}<a></li>
% endfor
</ul>
%endif
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nikola/data/themes/bootstrap3-jinja/assets/css/theme.css
Expand Up @@ -118,7 +118,7 @@ article.post-micro {
}

.metadata p:before,
.postlist .listdate:before {
.postlist .listdate:after {
content: " — ";
}

Expand Down
4 changes: 2 additions & 2 deletions nikola/data/themes/bootstrap3-jinja/assets/js/flowr.plugin.js
Expand Up @@ -180,7 +180,7 @@
}
} //utils

// If the resposive var is set to true then listen for resize method
// If the responsive var is set to true then listen for resize method
// and prevent resizing from happening twice if responsive is set again during append phase!
if (settings.responsive && !$this.data('__responsive')) {
$(window).resize(function() {
Expand Down Expand Up @@ -211,7 +211,7 @@
var currentItem = 0;

// Store all the data
var allData = $this.data('data') || [];
var allData = [];
for (i = 0; i < data.length; i++) {
allData.push(data[i]);
}
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/bootstrap3/assets/css/theme.css
Expand Up @@ -118,7 +118,7 @@ article.post-micro {
}

.metadata p:before,
.postlist .listdate:before {
.postlist .listdate:after {
content: " — ";
}

Expand Down
32 changes: 16 additions & 16 deletions nikola/filters.py
Expand Up @@ -142,54 +142,54 @@ def yui_compressor(infile):
raise Exception("yui-compressor is not installed.")
return False

return runinplace(r'{} --nomunge %1 -o %2'.format(yuicompressor), infile)
return runinplace('{} --nomunge %1 -o %2'.format(yuicompressor), infile)


def closure_compiler(infile):
"""Run closure-compiler on a file."""
return runinplace(r'closure-compiler --warning_level QUIET --js %1 --js_output_file %2', infile)
return runinplace('closure-compiler --warning_level QUIET --js %1 --js_output_file %2', infile)


def optipng(infile):
"""Run optipng on a file."""
return runinplace(r"optipng -preserve -o2 -quiet %1", infile)
return runinplace("optipng -preserve -o2 -quiet %1", infile)


def jpegoptim(infile):
"""Run jpegoptim on a file."""
return runinplace(r"jpegoptim -p --strip-all -q %1", infile)
return runinplace("jpegoptim -p --strip-all -q %1", infile)


def html_tidy_withconfig(infile):
def html_tidy_withconfig(infile, executable='tidy5'):
"""Run HTML Tidy with tidy5.conf as config file."""
return _html_tidy_runner(infile, r"-quiet --show-info no --show-warnings no -utf8 -indent -config tidy5.conf -modify %1")
return _html_tidy_runner(infile, "-quiet --show-info no --show-warnings no -utf8 -indent -config tidy5.conf -modify %1", executable=executable)


def html_tidy_nowrap(infile):
def html_tidy_nowrap(infile, executable='tidy5'):
"""Run HTML Tidy without line wrapping."""
return _html_tidy_runner(infile, r"-quiet --show-info no --show-warnings no -utf8 -indent --indent-attributes no --sort-attributes alpha --wrap 0 --wrap-sections no --drop-empty-elements no --tidy-mark no -modify %1")
return _html_tidy_runner(infile, "-quiet --show-info no --show-warnings no -utf8 -indent --indent-attributes no --sort-attributes alpha --wrap 0 --wrap-sections no --drop-empty-elements no --tidy-mark no -modify %1", executable=executable)


def html_tidy_wrap(infile):
def html_tidy_wrap(infile, executable='tidy5'):
"""Run HTML Tidy with line wrapping."""
return _html_tidy_runner(infile, r"-quiet --show-info no --show-warnings no -utf8 -indent --indent-attributes no --sort-attributes alpha --wrap 80 --wrap-sections no --drop-empty-elements no --tidy-mark no -modify %1")
return _html_tidy_runner(infile, "-quiet --show-info no --show-warnings no -utf8 -indent --indent-attributes no --sort-attributes alpha --wrap 80 --wrap-sections no --drop-empty-elements no --tidy-mark no -modify %1", executable=executable)


def html_tidy_wrap_attr(infile):
def html_tidy_wrap_attr(infile, executable='tidy5'):
"""Run HTML tidy with line wrapping and attribute indentation."""
return _html_tidy_runner(infile, r"-quiet --show-info no --show-warnings no -utf8 -indent --indent-attributes yes --sort-attributes alpha --wrap 80 --wrap-sections no --drop-empty-elements no --tidy-mark no -modify %1")
return _html_tidy_runner(infile, "-quiet --show-info no --show-warnings no -utf8 -indent --indent-attributes yes --sort-attributes alpha --wrap 80 --wrap-sections no --drop-empty-elements no --tidy-mark no -modify %1", executable=executable)


def html_tidy_mini(infile):
def html_tidy_mini(infile, executable='tidy5'):
"""Run HTML tidy with minimal settings."""
return _html_tidy_runner(infile, r"-quiet --show-info no --show-warnings no -utf8 --indent-attributes no --sort-attributes alpha --wrap 0 --wrap-sections no --tidy-mark no --drop-empty-elements no -modify %1")
return _html_tidy_runner(infile, "-quiet --show-info no --show-warnings no -utf8 --indent-attributes no --sort-attributes alpha --wrap 0 --wrap-sections no --tidy-mark no --drop-empty-elements no -modify %1", executable=executable)


def _html_tidy_runner(infile, options):
def _html_tidy_runner(infile, options, executable='tidy5'):
"""Run HTML Tidy."""
# Warnings (returncode 1) are not critical, and *everything* is a warning.
try:
status = runinplace(r"tidy5 " + options, infile)
status = runinplace(executable + " " + options, infile)
except subprocess.CalledProcessError as err:
status = 0 if err.returncode == 1 else err.returncode
return status
Expand Down
2 changes: 1 addition & 1 deletion nikola/nikola.py
Expand Up @@ -2207,7 +2207,7 @@ def generic_index_renderer(self, lang, posts, indexes_title, template_name, cont

def __repr__(self):
"""Representation of a Nikola site."""
return '<Nikola Site: {0!r}>'.format(self.config['BLOG_TITLE']())
return '<Nikola Site: {0!r}>'.format(self.config['BLOG_TITLE'](self.config['DEFAULT_LANG']))


def sanitized_locales(locale_fallback, locale_default, locales, translations):
Expand Down
27 changes: 21 additions & 6 deletions nikola/plugins/command/init.py
Expand Up @@ -221,6 +221,18 @@ def prepare_config(config):
return p


def test_destination(destination, demo=False):
"""Check if the destination already exists, which can break demo site creation."""
# Issue #2214
if demo and os.path.exists(destination):
LOGGER.warning("The directory {0} already exists, and a new demo site cannot be initialized in an existing directory.".format(destination))
LOGGER.warning("Please remove the directory and try again, or use another directory.")
LOGGER.info("Hint: If you want to initialize a git repository in this directory, run `git init` in the directory after creating a Nikola site.")
return False
else:
return True


class CommandInit(Command):
"""Create a new site."""

Expand Down Expand Up @@ -277,7 +289,7 @@ def create_empty_site(cls, target):
makedirs(os.path.join(target, folder))

@staticmethod
def ask_questions(target):
def ask_questions(target, demo=False):
"""Ask some questions about Nikola."""
def urlhandler(default, toconf):
answer = ask('Site URL', 'https://example.com/')
Expand Down Expand Up @@ -442,7 +454,7 @@ def chandler(default, toconf):
print("If you do not want to answer and want to go with the defaults instead, simply restart with the `-q` parameter.")

for query, default, toconf, destination in questions:
if target and destination == '!target':
if target and destination == '!target' and test_destination(target, demo):
# Skip the destination question if we know it already
pass
else:
Expand All @@ -459,8 +471,9 @@ def chandler(default, toconf):
if toconf:
SAMPLE_CONF[destination] = answer
if destination == '!target':
while not answer:
print(' ERROR: you need to specify a target directory.\n')
while not answer or not test_destination(answer, demo):
if not answer:
print(' ERROR: you need to specify a target directory.\n')
answer = ask(query, default)
STORAGE['target'] = answer

Expand All @@ -476,7 +489,7 @@ def _execute(self, options={}, args=None):
except IndexError:
target = None
if not options.get('quiet'):
st = self.ask_questions(target=target)
st = self.ask_questions(target=target, demo=options.get('demo'))
try:
if not target:
target = st['target']
Expand All @@ -489,11 +502,13 @@ def _execute(self, options={}, args=None):
Options:
-q, --quiet Do not ask questions about config.
-d, --demo Create a site filled with example data.""")
return False
return 1
if not options.get('demo'):
self.create_empty_site(target)
LOGGER.info('Created empty site at {0}.'.format(target))
else:
if not test_destination(target, True):
return 2
self.copy_sample_site(target)
LOGGER.info("A new site with example data has been created at "
"{0}.".format(target))
Expand Down

0 comments on commit 27d24b6

Please sign in to comment.