Fixing short sha1 computing

This commit is contained in:
Lucas Cimon 2017-12-05 00:03:59 +01:00
parent c1b90abf41
commit ae47bb989a
No known key found for this signature in database
GPG Key ID: 6AF36E0DE97FE852
13 changed files with 8 additions and 7 deletions

View File

@ -47,6 +47,7 @@ Features
* Share buttons built with share urls.
* Custom footer notice.
* W3C-Validated HTML
* Home page images lazy-loading
Install
-------
@ -78,7 +79,7 @@ If you want to use mg with search disabled.
DISABLE_SEARCH = True
```
###Optional settings
### Optional settings
**ALT_NAME**
An alternative name for your site. It appears in the header bar.

View File

@ -16,6 +16,8 @@ def sed(filepath, pattern, value):
# Generating CSS bundle
short_hash = sha1(cat('static/css/main.css')).hexdigest()[:7]
sed('templates/base.html', '-SHORTSHA1-[a-z0-9]+.css', '-SHORTSHA1-{}.css'.format(short_hash))
for DISABLE_SEARCH in range(2):
bundle = b''
bundle += cat('static/csslibs/uikit-2.27.4.min.css')
@ -24,13 +26,13 @@ for DISABLE_SEARCH in range(2):
bundle += cat('static/csslibs/tipuesearch.css')
bundle += cat('static/csslibs/solarized-highlight.css')
bundle += cat('static/css/main.css')
short_hash = sha1(bundle).hexdigest()[:7]
bundle_filename = 'bundle-DISABLE_SEARCH-{}-SHORTSHA1-{}.css'.format(DISABLE_SEARCH, short_hash)
with open('static/' + bundle_filename, 'wb') as bundle_file:
bundle_file.write(bundle)
sed('templates/base.html', '-SHORTSHA1-[a-z0-9]+.css', '-SHORTSHA1-{}.css'.format(short_hash))
# Generating JS bundle
short_hash = sha1(cat('static/js/enable-search.js') + cat('static/js/social.js') + cat('static/js/filter-tags.js')).hexdigest()[:7]
sed('templates/base.html', '-SHORTSHA1-[a-z0-9]+.js', '-SHORTSHA1-{}.js'.format(short_hash))
for DISABLE_SEARCH, SHARE, MG_FILTER_TAGS in itertools.product(range(2), repeat=3):
bundle = b''
bundle += cat('static/jslibs/html5shiv-3.7.2.min.js')
@ -48,9 +50,7 @@ for DISABLE_SEARCH, SHARE, MG_FILTER_TAGS in itertools.product(range(2), repeat=
bundle += cat('static/js/social.js')
if MG_FILTER_TAGS:
bundle += cat('static/js/filter-tags.js')
short_hash = sha1(bundle).hexdigest()[:7]
bundle_filename = 'bundle-DISABLE_SEARCH-{}-SHARE-{}-MG_FILTER_TAGS-{}-SHORTSHA1-{}.js'.format(
DISABLE_SEARCH, SHARE, MG_FILTER_TAGS, short_hash)
with open('static/' + bundle_filename, 'wb') as bundle_file:
bundle_file.write(bundle)
sed('templates/base.html', '-SHORTSHA1-[a-z0-9]+.js', '-SHORTSHA1-{}.js'.format(short_hash))

View File

@ -52,7 +52,7 @@
{% endif %}
{% endblock %}
<link rel="stylesheet" type="text/css" href="{{SITEURL}}/theme/bundle-DISABLE_SEARCH-{{DISABLE_SEARCH|string|first|length|string|first}}-SHORTSHA1-cf29250.css">
<link rel="stylesheet" type="text/css" href="{{SITEURL}}/theme/bundle-DISABLE_SEARCH-{{DISABLE_SEARCH|string|first|length|string|first}}-SHORTSHA1-9f3bed7.css">
</head>
<body>
<!--[if lt IE 7]>
@ -259,7 +259,7 @@
</div>
</aside>
<script src="{{SITEURL}}/theme/bundle-DISABLE_SEARCH-{{DISABLE_SEARCH|string|first|length|string|first}}-SHARE-{{SHARE|string|first|length|string|first}}-MG_FILTER_TAGS-{{MG_FILTER_TAGS|string|first|length|string|first}}-SHORTSHA1-e15c693.js"></script>
<script src="{{SITEURL}}/theme/bundle-DISABLE_SEARCH-{{DISABLE_SEARCH|string|first|length|string|first}}-SHARE-{{SHARE|string|first|length|string|first}}-MG_FILTER_TAGS-{{MG_FILTER_TAGS|string|first|length|string|first}}-SHORTSHA1-9eba27f.js"></script>
{% include 'disqus_count.html' %}
{% include 'analytics.html' %}