Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: getnikola/nikola
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ead8ce78dea1
Choose a base ref
...
head repository: getnikola/nikola
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ce5defe61c5e
Choose a head ref
  • 2 commits
  • 6 files changed
  • 1 contributor

Commits on Mar 17, 2018

  1. Make default theme easier to change

    Signed-off-by: Chris Warrick <kwpolska@gmail.com>
    Kwpolska committed Mar 17, 2018
    Copy the full SHA
    ebe33b2 View commit details
  2. Replace flowr.js with justified-layout.js (does not require jQuery!)

    Signed-off-by: Chris Warrick <kwpolska@gmail.com>
    Kwpolska committed Mar 17, 2018
    Copy the full SHA
    ce5defe View commit details
3 changes: 2 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@ New in master
Features
--------

* Replace ``flowr.js`` with ``justified-layout`` by Flickr
* Replace ``flowr.js`` with ``justified-layout.js`` by Flickr
(does not require jQuery!)
* ``bootblog4`` is the new default theme (Issue #2964)
* New ``bootstrap4`` and ``bootblog4`` themes (Issue #2964)
* New PRESERVE_ICC_PROFILES option to control whether ICC profiles are
81 changes: 41 additions & 40 deletions nikola/data/themes/base/templates/gallery.tmpl
Original file line number Diff line number Diff line change
@@ -43,13 +43,13 @@
${parent.extra_head()}
<link rel="alternate" type="application/rss+xml" title="RSS" href="rss.xml">
<style type="text/css">
.image-block {
display: inline-block;
#gallery_container {
position: relative;
}
.flowr_row {
width: 100%;
.image-block {
position: absolute;
}
</style>
</style>
%if len(translations) > 1:
%for langname in translations.keys():
%if langname != lang:
@@ -61,45 +61,46 @@ ${parent.extra_head()}
</%block>

<%block name="extra_js">
<script src="/assets/js/flowr.js"></script>
<script src="/assets/js/justified-layout.min.js"></script>
<script>
jsonContent = ${photo_array_json};
flowr(document.querySelectorAll("#gallery_container")[0], {
data : jsonContent,
height : ${thumbnail_size}*.6,
padding: 5,
rows: -1,
render : function(params) {
// Just return a div, string or a dom object, anything works fine
var img = document.createElement("img");
img.setAttribute('src', params.itemData.url_thumb);
img.setAttribute('width', params.width);
img.setAttribute('height', params.height);
img.setAttribute('alt', params.itemData.title);
img.style.maxWidth = '100%';
link = document.createElement("a");
link.setAttribute('href', params.itemData.url);
link.setAttribute('class', 'image-reference');
div = document.createElement("div");
div.setAttribute('class', 'image-block');
div.setAttribute('title', params.itemData.title);
div.setAttribute('data-toggle', "tooltip")
link.append(img);
div.append(link);
//div.hover(div.tooltip());
return div;
},
itemWidth : function(data) { return data.size.w; },
itemHeight : function(data) { return data.size.h; },
complete : function(params) {
if( jsonContent.length > params.renderedItems ) {
nextRenderList = jsonContent.slice( params.renderedItems );
}
}
});
var jsonContent = ${photo_array_json};

function renderGallery() {
var container = document.getElementById("gallery_container");
container.innerHTML = '';
var layoutGeometry = require('justified-layout')(jsonContent, {
"containerWidth": container.offsetWidth,
"targetRowHeight": ${thumbnail_size}*.6,
"boxSpacing": 5});
container.style.height = layoutGeometry.containerHeight + 'px';
var boxes = layoutGeometry.boxes;
for (var i = 0; i < boxes.length; i++) {
var img = document.createElement("img");
img.setAttribute('src', jsonContent[i].url_thumb);
img.setAttribute('alt', jsonContent[i].title);
img.style.width = boxes[i].width + 'px';
img.style.height = boxes[i].height + 'px';
link = document.createElement("a");
link.setAttribute('href', jsonContent[i].url);
link.setAttribute('class', 'image-reference');
div = document.createElement("div");
div.setAttribute('class', 'image-block');
div.setAttribute('title', jsonContent[i].title);
div.setAttribute('data-toggle', "tooltip")
div.style.width = boxes[i].width + 'px';
div.style.height = boxes[i].height + 'px';
div.style.top = boxes[i].top + 'px';
div.style.left = boxes[i].left + 'px';
link.append(img);
div.append(link);
container.append(div);
}
baguetteBox.run('#gallery_container', {
captions: function(element) {
return element.getElementsByTagName('img')[0].alt;
}});
}
renderGallery();
window.addEventListener('resize', renderGallery);
</script>
</%block>
85 changes: 43 additions & 42 deletions nikola/data/themes/bootstrap4/templates/gallery.tmpl
Original file line number Diff line number Diff line change
@@ -42,13 +42,13 @@ ${comments.comment_form(None, permalink, title)}
${parent.extra_head()}
<link rel="alternate" type="application/rss+xml" title="RSS" href="rss.xml">
<style type="text/css">
.image-block {
display: inline-block;
#gallery_container {
position: relative;
}
.flowr_row {
width: 100%;
.image-block {
position: absolute;
}
</style>
</style>
%if len(translations) > 1:
%for langname in translations.keys():
%if langname != lang:
@@ -58,46 +58,47 @@ ${parent.extra_head()}
%endif
</%block>


<%block name="extra_js">
<script src="/assets/js/flowr.js"></script>
<script src="/assets/js/justified-layout.min.js"></script>
<script>
jsonContent = ${photo_array_json};
$("#gallery_container").flowr({
data : jsonContent,
height : ${thumbnail_size}*.6,
padding: 5,
rows: -1,
render : function(params) {
// Just return a div, string or a dom object, anything works fine
img = $("<img />").attr({
'src': params.itemData.url_thumb,
'width' : params.width,
'height' : params.height
}).css('max-width', '100%');
link = $( "<a></a>").attr({
'href': params.itemData.url,
'class': 'image-reference'
});
div = $("<div />").addClass('image-block').attr({
'title': params.itemData.title,
'data-toggle': "tooltip",
});
link.append(img);
div.append(link);
div.hover(div.tooltip());
return div;
},
itemWidth : function(data) { return data.size.w; },
itemHeight : function(data) { return data.size.h; },
complete : function(params) {
if( jsonContent.length > params.renderedItems ) {
nextRenderList = jsonContent.slice( params.renderedItems );
}
}
});
var jsonContent = ${photo_array_json};

function renderGallery() {
var container = document.getElementById("gallery_container");
container.innerHTML = '';
var layoutGeometry = require('justified-layout')(jsonContent, {
"containerWidth": container.offsetWidth,
"targetRowHeight": ${thumbnail_size}*.6,
"boxSpacing": 5});
container.style.height = layoutGeometry.containerHeight + 'px';
var boxes = layoutGeometry.boxes;
for (var i = 0; i < boxes.length; i++) {
var img = document.createElement("img");
img.setAttribute('src', jsonContent[i].url_thumb);
img.setAttribute('alt', jsonContent[i].title);
img.style.width = boxes[i].width + 'px';
img.style.height = boxes[i].height + 'px';
link = document.createElement("a");
link.setAttribute('href', jsonContent[i].url);
link.setAttribute('class', 'image-reference');
div = document.createElement("div");
div.setAttribute('class', 'image-block');
div.setAttribute('title', jsonContent[i].title);
div.setAttribute('data-toggle', "tooltip")
div.style.width = boxes[i].width + 'px';
div.style.height = boxes[i].height + 'px';
div.style.top = boxes[i].top + 'px';
div.style.left = boxes[i].left + 'px';
link.append(img);
div.append(link);
container.append(div);
}
baguetteBox.run('#gallery_container', {
captions: function(element) {
return element.getElementsByTagName('img')[0].alt;
}});</script>
}});
}
renderGallery();
window.addEventListener('resize', renderGallery);
</script>
</%block>
10 changes: 6 additions & 4 deletions nikola/nikola.py
Original file line number Diff line number Diff line change
@@ -97,6 +97,7 @@

# We store legal values for some settings here. For internal use.
LEGAL_VALUES = {
'DEFAULT_THEME': 'bootblog4',
'COMMENT_SYSTEM': [
'disqus',
'facebook',
@@ -602,7 +603,7 @@ def __init__(self, **config):
'TAGS_INDEX_PATH': '',
'TAGLIST_MINIMUM_POSTS': 1,
'TEMPLATE_FILTERS': {},
'THEME': 'bootblog4',
'THEME': LEGAL_VALUES['DEFAULT_THEME'],
'THEME_COLOR': '#5670d4', # light "corporate blue"
'THUMBNAIL_SIZE': 180,
'TRANSLATIONS_PATTERN': '{path}.{lang}.{ext}',
@@ -1205,9 +1206,10 @@ def _get_themes(self):
try:
self._THEMES = utils.get_theme_chain(self.config['THEME'], self.themes_dirs)
except Exception:
if self.config['THEME'] != 'bootblog4':
utils.LOGGER.warn('''Cannot load theme "{0}", using 'bootblog4' instead.'''.format(self.config['THEME']))
self.config['THEME'] = 'bootblog4'
if self.config['THEME'] != LEGAL_VALUES['DEFAULT_THEME']:
utils.LOGGER.warn('''Cannot load theme "{0}", using '{1}' instead.'''.format(
self.config['THEME'], LEGAL_VALUES['DEFAULT_THEME']))
self.config['THEME'] = LEGAL_VALUES['DEFAULT_THEME']
return self._get_themes()
raise
# Check consistency of USE_CDN and the current THEME (Issue #386)
4 changes: 2 additions & 2 deletions nikola/plugins/command/init.py
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
import tarfile

import nikola
from nikola.nikola import DEFAULT_INDEX_READ_MORE_LINK, DEFAULT_FEED_READ_MORE_LINK, LEGAL_VALUES, urlsplit, urlunsplit
from nikola.nikola import LEGAL_VALUES, DEFAULT_INDEX_READ_MORE_LINK, DEFAULT_FEED_READ_MORE_LINK, LEGAL_VALUES, urlsplit, urlunsplit
from nikola.plugin_categories import Command
from nikola.utils import ask, ask_yesno, get_logger, makedirs, load_messages
from nikola.packages.tzlocal import get_localzone
@@ -62,7 +62,7 @@
# Example for another language:
# "es": "./es",
}""",
'THEME': 'bootblog4',
'THEME': LEGAL_VALUES['DEFAULT_THEME'],
'TIMEZONE': 'UTC',
'COMMENT_SYSTEM': 'disqus',
'COMMENT_SYSTEM_ID': 'nikolademo',
2 changes: 2 additions & 0 deletions nikola/plugins/task/galleries.py
Original file line number Diff line number Diff line change
@@ -590,6 +590,8 @@ def url_from_path(p):
'w': w,
'h': h
},
'width': w,
'height': h
})
context['photo_array'] = photo_array
context['photo_array_json'] = json.dumps(photo_array, sort_keys=True)