Skip to content

Commit

Permalink
Merge branch 'master' into import_page
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Aug 24, 2015
2 parents efabecc + 63ac9a4 commit 9b8e937
Show file tree
Hide file tree
Showing 23 changed files with 329 additions and 30 deletions.
12 changes: 10 additions & 2 deletions output/index.html
Expand Up @@ -279,25 +279,33 @@ <h2>Plugins for Nikola <small>version
// DEFAULT VERSION SET HERE
var current_version = 7;
var already_initialized = false;
var canonical = document.querySelector('link[rel="canonical"]');
fetch(current_version);
already_initialized = true;
function hash_handler() {
if (location.hash) {
plugin = location.hash.slice(1);
canonical.href = 'https://plugins.getnikola.com/#' + plugin;
}
else {
plugin = null;
canonical.href = 'https://plugins.getnikola.com/';
}
// Show plugin data
container = $('#rightside');
container.html('');
if (plugin === null) {
var title = $('<h2/>').text("Choose a plugin…").appendTo(container);
$('</p>').text("Pick a plugin from the list on the left to display more information.").appendTo(container);
} else {
var title = $('<h2/>').text(plugin).appendTo(container);
var small = $('<small/>').appendTo(title);
$('<span/>').html('&nbsp;v'+data[plugin]['version']).appendTo(small)
$('<span/>').html('&nbsp;|&nbsp;by '+data[plugin]['author']).appendTo(small)
if (['website'] in data[plugin]) {
author_str = '<a href="' + data[plugin]['website'] + '">' + data[plugin]['author'] + '</a>';
} else {
author_str = data[plugin]['author'];
}
$('<span/>').html('&nbsp;|&nbsp;by ' + author_str).appendTo(small)
if (data[plugin]['tests']) {
$('<span/>').html('&nbsp;|&nbsp;Tests exist (' +
data[plugin]['tests'] + ')').appendTo(small)
Expand Down
4 changes: 4 additions & 0 deletions scripts/build_site.py
Expand Up @@ -88,6 +88,10 @@ def get_data(path):
data['author'] = c.get('Documentation', 'Author')
data['version'] = c.get('Documentation', 'Version')
data['description'] = c.get('Documentation', 'Description')
try:
data['website'] = c.get('Documentation', 'Website')
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
data['website'] = None
try:
data['minver'] = c.get('Nikola', 'MinVersion')
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
Expand Down
17 changes: 6 additions & 11 deletions tests/base.py
Expand Up @@ -9,12 +9,9 @@
__all__ = ["BaseTestCase", "cd", "LocaleSupportInTesting"]


# This code is so you can run the samples without installing the package,
# and should be before any import touching nikola, in any file under tests/
import os
import sys
extra_v6_plugin_dir = os.path.join(os.path.dirname(__file__), '..', 'v6')
sys.path.insert(0, extra_v6_plugin_dir)


from contextlib import contextmanager
import locale
Expand Down Expand Up @@ -204,11 +201,10 @@ def __init__(self):
self.config = {
'DISABLED_PLUGINS': [],
'EXTRA_PLUGINS': [],
'EXTRA_PLUGINS_DIRS': [extra_v6_plugin_dir],
'DEFAULT_LANG': 'en',
'MARKDOWN_EXTENSIONS': ['fenced_code', 'codehilite'],
'TRANSLATIONS_PATTERN': '{path}.{lang}.{ext}',
'LISTINGS_FOLDERS': {},
'LISTINGS_FOLDERS': {'listings': 'listings'},
}
self.EXTRA_PLUGINS = self.config['EXTRA_PLUGINS']
self.plugin_manager = PluginManager(categories_filter={
Expand All @@ -219,20 +215,19 @@ def __init__(self):
"PageCompiler": PageCompiler,
"TaskMultiplier": TaskMultiplier,
"CompilerExtension": CompilerExtension,
"RestExtension": RestExtension,
"MarkdownExtension": MarkdownExtension,
"RestExtension": RestExtension
})
self.loghandlers = [nikola.utils.STDERR_HANDLER]
self.loghandlers = nikola.utils.STDERR_HANDLER # TODO remove on v8
self.plugin_manager.setPluginInfoExtension('plugin')
extra_plugins_dirs = self.config['EXTRA_PLUGINS_DIRS']
if sys.version_info[0] == 3:
places = [
os.path.join(os.path.dirname(nikola.utils.__file__), 'plugins'),
] + [path for path in extra_plugins_dirs if path]
]
else:
places = [
os.path.join(os.path.dirname(nikola.utils.__file__), nikola.utils.sys_encode('plugins')),
] + [nikola.utils.sys_encode(path) for path in extra_plugins_dirs if path]
]
self.plugin_manager.setPluginPlaces(places)
self.plugin_manager.collectPlugins()
self.compiler_extensions = self._activate_plugins_of_category("CompilerExtension")
Expand Down
1 change: 1 addition & 0 deletions tests/test_command_tags.py
Expand Up @@ -60,6 +60,7 @@ def _init_site(self):
sys.path.pop(0)

self._site = nikola.Nikola(**conf.__dict__)
self._site.init_plugins()

def _parse_new_tags(self, source):
""" Returns the new tags for a post, given it's source path. """
Expand Down
11 changes: 10 additions & 1 deletion v6/orgmode/init.el
Expand Up @@ -37,6 +37,15 @@


;;; Code highlighting ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun org-html-decode-plain-text (text)
"Convert HTML character to plain TEXT. i.e. do the inversion of
`org-html-encode-plain-text`. Possible conversions are set in
`org-html-protect-char-alist'."
(mapc
(lambda (pair)
(setq text (replace-regexp-in-string (cdr pair) (car pair) text t t)))
(reverse org-html-protect-char-alist))
text)

;; Use pygments highlighting for code
(defun pygmentize (lang code)
Expand Down Expand Up @@ -104,7 +113,7 @@ contextual information."
(let ((lang (org-element-property :language src-block))
(code (org-html-format-code src-block info)))
(if nikola-use-pygments
(pygmentize lang code)
(pygmentize lang (org-html-decode-plain-text code))
code))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
2 changes: 1 addition & 1 deletion v7/navstories/navstories.plugin
Expand Up @@ -6,7 +6,7 @@ Module = navstories
MinVersion = 7.1.0+

[Documentation]
Author = Chris “Kwpolska” Warrick
Author = Chris Warrick
Version = 0.1.0
Website = http://plugins.getnikola.com/#navstories
Description = Add all stories to the navigation bar.
2 changes: 1 addition & 1 deletion v7/navstories/navstories.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# Copyright © 2014 Chris “Kwpolska” Warrick and others.
# Copyright © 2014 Chris Warrick and others.

# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
Expand Down
2 changes: 1 addition & 1 deletion v7/projectpages/projectpages.plugin
Expand Up @@ -8,5 +8,5 @@ MinVersion = 7.1.0+
[Documentation]
Author = Chris Warrick
Version = 0.1.6
Website = http://plugins.getnikola.com/#projectpages
Website = https://chriswarrick.com/projects/
Description = Generate project pages
4 changes: 2 additions & 2 deletions v7/recent_posts_json/recent_posts_json.plugin
Expand Up @@ -4,7 +4,7 @@ Module = recent_posts_json

[Documentation]
Author = Daniel Aleksandersen
Version = 0.9.0
Website = https://www.aeyoun.com
Version = 1.0.0
Website = https://www.aeyoun.com/projects/nikola/
Description = Generate JSON with recent posts.

6 changes: 3 additions & 3 deletions v7/recent_posts_json/recent_posts_json.py
Expand Up @@ -95,14 +95,14 @@ def make_json(self, posts, descriptions, previewimage, output_path):
link = post.permalink(absolute=False)
title = post.title()
entry = {"date": date,
"title": title,
"loc": link}
"loc": link,
"title": title}
if descriptions:
entry.update({["desc"]: post.description()})
if previewimage:
entry.update({["img"]: post.previewimage()})
recent_posts.append(entry)
data = json.dumps(recent_posts, indent=2)
data = json.dumps(recent_posts, indent=2, sort_keys=True)
with io.open(output_path, "w+", encoding="utf8") as outf:
outf.write(data)

Expand Down
2 changes: 1 addition & 1 deletion v7/sass/sass.plugin
Expand Up @@ -3,7 +3,7 @@ Name = sass
Module = sass

[Documentation]
Author = Roberto Alsina, Chris "Kwpolska" Warrick
Author = Roberto Alsina, Chris Warrick
Version = 0.1
Website = http://plugins.getnikola.com/#sass
Description = Build CSS out of Sass sources
11 changes: 11 additions & 0 deletions v7/tx3_tag_cloud/README.md
@@ -0,0 +1,11 @@
Use tx3TagCloud to render our tags in a pretty web:

* https://github.com/Tuxes3/tx3TagCloud

**YOU HAVE TO COPY** the template
`tx3_tag_cloud/templates/mako/tags.tmpl` in your THEME folder to make
it work properly. This templates includes the JS and CSS files needed
to render tx3TagCloud and also removes the tags rendered in the old
way.

Something like: `<your-nikola-site>/themes/<your-theme>/templates/`
Empty file added v7/tx3_tag_cloud/conf.py.sample
Empty file.
30 changes: 30 additions & 0 deletions v7/tx3_tag_cloud/files/assets/css/tx3-tag-cloud.css
@@ -0,0 +1,30 @@
ul.tx3-tag-cloud
{

}

ul.tx3-tag-cloud li
{
display: block;
float: left;
list-style: none;
margin-right: 4px;
}

ul.tx3-tag-cloud li a
{
display: block;
text-decoration: none;
color: #c9c9c9;
padding: 3px 10px;
}

ul.tx3-tag-cloud li a:hover
{
color: #000000;
-webkit-transition: color 250ms linear;
-moz-transition: color 250ms linear;
-o-transition: color 250ms linear;
-ms-transition: color 250ms linear;
transition: color 250ms linear;
}
70 changes: 70 additions & 0 deletions v7/tx3_tag_cloud/files/assets/js/jquery.tx3-tag-cloud.js
@@ -0,0 +1,70 @@
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* Tuxes3 wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return Tuxes3
* ----------------------------------------------------------------------------
*/
(function($)
{
var settings;
$.fn.tx3TagCloud = function(options)
{

//
// DEFAULT SETTINGS
//
settings = $.extend({
multiplier : 1
}, options);
main(this);

}

function main(element)
{
// adding style attr
element.addClass("tx3-tag-cloud");
addListElementFontSize(element);
}

/**
* calculates the font size on each li element
* according to their data-weight attribut
*/
function addListElementFontSize(element)
{
var hDataWeight = -9007199254740992;
var lDataWeight = 9007199254740992;
$.each(element.find("li"), function(){
cDataWeight = getDataWeight(this);
if (cDataWeight == undefined)
{
logWarning("No \"data-weight\" attribut defined on <li> element");
}
else
{
hDataWeight = cDataWeight > hDataWeight ? cDataWeight : hDataWeight;
lDataWeight = cDataWeight < lDataWeight ? cDataWeight : lDataWeight;
}
});
$.each(element.find("li"), function(){
var dataWeight = getDataWeight(this);
var percent = Math.abs((dataWeight - lDataWeight)/(lDataWeight - hDataWeight));
$(this).css('font-size', (1 + (percent * settings['multiplier'])) + "em");
});

}

function getDataWeight(element)
{
return parseInt($(element).attr("data-weight"));
}

function logWarning(message)
{
console.log("[WARNING] " + Date.now() + " : " + message);
}

}(jQuery));
21 changes: 21 additions & 0 deletions v7/tx3_tag_cloud/files/assets/js/tx3-tag-cloud.js
@@ -0,0 +1,21 @@
function create_li_tags() {
$.getJSON("/assets/js/tx3_tag_cloud.json", function(data){
var items = [];
$.each(data, function(key, val){
var count = val[0]
var url = val[1]
var posts = val[2]
items.push("<li data-weight='" + count + "'><a href='" + url + "'>" + key + "</a></li>");
});

$("<ul/>", {
"id": "tagcloud",
html: items.join("")
}).appendTo("div.row");

$("#tagcloud").tx3TagCloud({
multiplier: 5 // default multiplier is "1"
});
});
}
create_li_tags();
44 changes: 44 additions & 0 deletions v7/tx3_tag_cloud/templates/mako/tags.tmpl
@@ -0,0 +1,44 @@
## -*- coding: utf-8 -*-
<%inherit file="base.tmpl"/>

<%block name="extra_head">
${parent.extra_head()}
<link href="/assets/css/tx3-tag-cloud.css" rel="stylesheet" type="text/css">
<style>
li {
line-height: 70px !important;
}
</style>
</%block>

<%block name="content">
<h1>${title}</h1>
% if cat_items:
% if items:
<h2>${messages("Categories")}</h2>
% endif
% for text, full_name, path, link, indent_levels, indent_change_before, indent_change_after in cat_hierarchy:
% for i in range(indent_change_before):
<ul class="unstyled">
% endfor
<li><a class="reference badge" href="${link}">${text}</a>
% if indent_change_after <= 0:
</li>
% endif
% for i in range(-indent_change_after):
</ul>
% if i + 1 < len(indent_levels):
</li>
% endif
% endfor
% endfor
% if items:
<h2>${messages("Tags")}</h2>
% endif
%endif
</%block>

<%block name="extra_js">
<script type="text/javascript" src="/assets/js/jquery.tx3-tag-cloud.js"></script>
<script type="text/javascript" src="/assets/js/tx3-tag-cloud.js"></script>
</%block>
12 changes: 12 additions & 0 deletions v7/tx3_tag_cloud/tx3_tag_cloud.plugin
@@ -0,0 +1,12 @@
[Core]
Name = tx3TagCloud
Module = tx3_tag_cloud

[Nikola]
MinVersion = 7.6.3

[Documentation]
Author = Manuel Kaufmann
Version = 0.1
Website = http://plugins.getnikola.com/#tx3_tag_cloud
Description = Show tags in a pretty way using tx3TagCloud (https://github.com/Tuxes3/tx3TagCloud)

0 comments on commit 9b8e937

Please sign in to comment.