Skip to content

Commit

Permalink
Merge branch 'master' into fix-3140
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwpolska committed Sep 3, 2018
2 parents 55f0f43 + 38c75fa commit a46ab61
Show file tree
Hide file tree
Showing 22 changed files with 265 additions and 734 deletions.
7 changes: 7 additions & 0 deletions CHANGES.txt
Expand Up @@ -6,6 +6,7 @@ New since Beta 3
Features
--------

* Add Vietnamese translation by Hoai-Thu Vuong
* Don’t generate gallery index if the destination directory is
site root and it would conflict with blog index (Issue #3133)
* All built-in themes now support ``updated`` timestamp fields in
Expand All @@ -23,6 +24,12 @@ Bugfixes
* Enforce trailing slash for directories in ``nikola auto``
(Issue #3140)

Removed features
----------------

* The ``webassets`` library is no longer required, we now manually
bundle files (Issue #3074)

New in v8.0.0b3 (changes since Beta 2)
======================================

Expand Down
2 changes: 1 addition & 1 deletion docs/creating-a-theme.rst
Expand Up @@ -813,7 +813,7 @@ Doing the same for layout-reverse, sidebar-overlay and the rest is left as an ex
Bundles
-------

If you have ``webassets`` installed and the ``USE_BUNDLES`` option set to True,
If the ``USE_BUNDLES`` option set to True,
Nikola can put several CSS or JS files together in a larger file, which can
makes site load faster for some deployments. To do this, your theme needs
a ``bundles`` file. The file format is a modified
Expand Down
2 changes: 1 addition & 1 deletion docs/manual.rst
Expand Up @@ -2342,7 +2342,7 @@ different ones, or about other web servers, please share!
4. Optionally you can create static compressed copies and save some CPU on your server
with the GZIP_FILES option in Nikola.

5. The webassets Nikola plugin can drastically decrease the number of CSS and JS files your site fetches.
5. The bundles Nikola plugin can drastically decrease the number of CSS and JS files your site fetches.

6. Through the filters feature, you can run your files through arbitrary commands, so that images
are recompressed, JavaScript is minimized, etc.
Expand Down
5 changes: 2 additions & 3 deletions docs/theming.rst
Expand Up @@ -74,8 +74,7 @@ parent, engine

bundles
A `config <https://docs.python.org/3/library/configparser.html>`_ file
containing a list of files to be turned into bundles using WebAssets. For
example:
containing a list of files to be turned into bundles. For example:

.. code:: ini
Expand All @@ -93,7 +92,7 @@ bundles
This makes the page much more efficient because it avoids multiple connections to the server,
at the cost of some extra difficult debugging.

WebAssets supports bundling CSS and JS files.
Bundling applies to CSS and JS files.

Templates should use either the bundle or the individual files based on the ``use_bundles``
variable, which in turn is set by the ``USE_BUNDLES`` option.
Expand Down
6 changes: 3 additions & 3 deletions nikola/conf.py.in
Expand Up @@ -1191,9 +1191,9 @@ MARKDOWN_EXTENSIONS = ['markdown.extensions.fenced_code', 'markdown.extensions.c
# # 'creator': '@username', # Username for the content creator / author.
# }

# If webassets is installed, bundle JS and CSS into single files to make
# site loading faster in a HTTP/1.1 environment but is not recommended for
# HTTP/2.0 when caching is used. Defaults to True.
# Bundle JS and CSS into single files to make site loading faster in a HTTP/1.1
# environment but is not recommended for HTTP/2.0 when caching is used.
# Defaults to True.
# USE_BUNDLES = True

# Plugins you don't want to use. Be careful :-)
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/base/messages/messages_de.py
Expand Up @@ -45,5 +45,5 @@
"Write your post here.": "Schreibe hier deinen Eintrag hin.",
"old posts, page %d": "Ältere Einträge, Seite %d",
"page %d": "Seite %d",
"updated": "",
"updated": "aktualisiert",
}
2 changes: 1 addition & 1 deletion nikola/data/themes/base/messages/messages_fi.py
Expand Up @@ -45,5 +45,5 @@
"Write your post here.": "Kirjoita sisältö tähän.",
"old posts, page %d": "vanhoja kirjoituksia, sivu %d",
"page %d": "sivu %d",
"updated": "",
"updated": "päivitetty",
}
2 changes: 1 addition & 1 deletion nikola/data/themes/base/messages/messages_nl.py
Expand Up @@ -45,5 +45,5 @@
"Write your post here.": "Schrijf hier je bericht.",
"old posts, page %d": "oude berichten, pagina %d",
"page %d": "pagina %d",
"updated": "",
"updated": "bijgewerkt",
}
49 changes: 49 additions & 0 deletions nikola/data/themes/base/messages/messages_vi.py
@@ -0,0 +1,49 @@
# -*- encoding:utf-8 -*-
"""Autogenerated file, do not edit. Submit translations on Transifex."""

MESSAGES = {
"%d min remaining to read": "Cần %d phút để đọc",
"(active)": "(active)",
"Also available in:": "Cũng có sẵn trong:",
"Archive": "Kho",
"Atom feed": "Nguồn cung cấp dữ liệu Atom",
"Authors": "Tác giả",
"Categories": "Thể loại",
"Comments": "Bình luận",
"LANGUAGE": "Tiếng Việt",
"Languages:": "Ngôn ngữ:",
"More posts about %s": "Các bài đăng khác về %s",
"Newer posts": "Bài viết gần đây",
"Next post": "Bài viết tiếp theo",
"Next": "Kế tiếp",
"No posts found.": "Không tìm thấy bài viết.",
"Nothing found.": "Không có kết quả.",
"Older posts": "Bài viết trước đây",
"Original site": "Trang gốc",
"Posted:": "Đã đăng:",
"Posts about %s": "Bài viết về %s",
"Posts by %s": "Bài đăng bởi %s",
"Posts for year %s": "Các bài viết trong năm %s",
"Posts for {month_day_year}": "Các bài đã đăng {month_day_year}",
"Posts for {month_year}": "Các bài đã đăng {month_year}",
"Previous post": "Bài viết trước",
"Previous": "Trước",
"Publication date": "Ngày phát hành",
"RSS feed": "Nguồn cung cấp dữ liệu RSS",
"Read in English": "Phiên bản Tiếng Việt",
"Read more": "Đọc thêm",
"Skip to main content": "Chuyển đến nội dung chính",
"Source": "Nguồn",
"Subcategories:": "Thể loại con:",
"Tags and Categories": "Thẻ và Thể loại",
"Tags": "Thẻ",
"Toggle navigation": "Chuyển điều hướng",
"Uncategorized": "Chưa được phân loại",
"Up": "Trở lên",
"Updates": "Cập nhật",
"Write your page here.": "Bắt đầu viết nội dung của trang ở đây.",
"Write your post here.": "Bắt đầu viết bài ở đây.",
"old posts, page %d": "các bài viết trước đây, trang %d",
"page %d": "trang %d",
"updated": "Đã được cập nhật",
}
2 changes: 2 additions & 0 deletions nikola/nikola.py
Expand Up @@ -151,6 +151,7 @@
('tr', '!tr_TR'): 'Turkish',
'uk': 'Ukrainian',
'ur': 'Urdu',
'vi': 'Vietnamese',
'zh_cn': 'Chinese (Simplified)',
'zh_tw': 'Chinese (Traditional)'
},
Expand Down Expand Up @@ -216,6 +217,7 @@
th='th',
uk='uk',
ur='ur',
vi='vi',
zh_cn='zh-cn',
zh_tw='zh-tw'
),
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/task/bundles.plugin
Expand Up @@ -6,7 +6,7 @@ module = bundles
author = Roberto Alsina
version = 1.0
website = https://getnikola.com/
description = Theme bundles using WebAssets
description = Bundle assets

[Nikola]
PluginCategory = Task
Expand Down
54 changes: 17 additions & 37 deletions nikola/plugins/task/bundles.py
Expand Up @@ -24,39 +24,26 @@
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

"""Bundle assets using WebAssets."""
"""Bundle assets."""


import configparser
import io
import itertools
import os

try:
import webassets
except ImportError:
webassets = None # NOQA
import shutil

from nikola.plugin_categories import LateTask
from nikola import utils


class BuildBundles(LateTask):
"""Bundle assets using WebAssets."""
"""Bundle assets."""

name = "create_bundles"

def set_site(self, site):
"""Set Nikola site."""
super(BuildBundles, self).set_site(site)
if webassets is None and site.configured and site.config['USE_BUNDLES']:
utils.req_missing(['webassets'], 'USE_BUNDLES', optional=True)
self.logger.warn('Setting USE_BUNDLES to False.')
site.config['USE_BUNDLES'] = False
site._GLOBAL_CONTEXT['use_bundles'] = False

def gen_tasks(self):
"""Bundle assets using WebAssets."""
"""Bundle assets."""
kw = {
'filters': self.site.config['FILTERS'],
'output_folder': self.site.config['OUTPUT_FOLDER'],
Expand All @@ -70,28 +57,21 @@ def gen_tasks(self):
def build_bundle(output, inputs):
out_dir = os.path.join(kw['output_folder'],
os.path.dirname(output))
inputs = [os.path.relpath(i, out_dir) for i in inputs if os.path.isfile(i)]
cache_dir = os.path.join(kw['cache_folder'], 'webassets')
utils.makedirs(cache_dir)
env = webassets.Environment(out_dir, os.path.dirname(output),
cache=cache_dir)
if inputs:
bundle = webassets.Bundle(*inputs, output=os.path.basename(output))
env.register(output, bundle)
# This generates the file
try:
env[output].build(force=True)
except Exception as e:
self.logger.error("Failed to build bundles.")
self.logger.exception(e)
self.logger.notice("Try running ``nikola clean`` and building again.")
else:
with open(os.path.join(out_dir, os.path.basename(output)), 'wb+'):
pass # Create empty file
inputs = [
os.path.join(
out_dir,
os.path.relpath(i, out_dir))
for i in inputs if os.path.isfile(i)
]
with open(os.path.join(out_dir, os.path.basename(output)), 'wb+') as out_fh:
for i in inputs:
with open(i, 'rb') as in_fh:
shutil.copyfileobj(in_fh, out_fh)
out_fh.write(b'\n')

yield self.group_task()
if (webassets is not None and self.site.config['USE_BUNDLES'] is not
False):

if self.site.config['USE_BUNDLES']:
for name, _files in kw['theme_bundles'].items():
output_path = os.path.join(kw['output_folder'], name)
dname = os.path.dirname(name)
Expand Down
1 change: 0 additions & 1 deletion requirements-extras.txt
Expand Up @@ -6,7 +6,6 @@ micawber>=0.3.0
pygal>=2.0.0
typogrify>=2.0.4
phpserialize>=1.3
webassets>=0.10.1
notebook>=4.0.0
ipykernel>=4.0.0
ghp-import2>=1.0.0
Expand Down
2 changes: 1 addition & 1 deletion requirements-tests.txt
@@ -1,7 +1,7 @@
-r requirements-extras.txt
mock==2.0.0
coverage==4.5.1
pytest==3.7.1
pytest==3.7.4
pytest-cov==2.5.1
freezegun==0.3.10
codacy-coverage==1.3.11
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Expand Up @@ -9,7 +9,7 @@ unidecode>=0.04.16
lxml>=3.3.5
Yapsy>=1.11.223
PyRSS2Gen>=1.1
logbook>=0.7.0
logbook>=1.3.0
blinker>=1.3
setuptools>=24.2.0
natsort>=3.5.2
Expand Down
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -126,7 +126,6 @@ def run(self):
'Topic :: Text Processing :: Markup'),
install_requires=dependencies,
extras_require=extras,
tests_require=['pytest'],
include_package_data=True,
python_requires='>=3.4',
cmdclass={'install': nikola_install},
Expand Down
1 change: 0 additions & 1 deletion snapcraft.yaml
Expand Up @@ -28,7 +28,6 @@ parts:
- pygal>=2.0.0
- typogrify>=2.0.4
- phpserialize>=1.3
- webassets>=0.10.1
- ghp-import2>=1.0.0
- ws4py==0.3.5
- watchdog==0.8.3
Expand Down

0 comments on commit a46ab61

Please sign in to comment.