Skip to content
Permalink
Browse files

Fix #72, #76 -- remove .git files from zipballs

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Apr 6, 2016
1 parent 726cf7b commit 1cca360369063084b2dd041fb2f43f1b8e4d5395
Showing with 17 additions and 2 deletions.
  1. +17 −2 scripts/build_themes.py
@@ -4,14 +4,14 @@

from __future__ import unicode_literals, print_function
import io
import tempfile
from contextlib import contextmanager
import glob
import json
import os
import sys
import shutil
import subprocess
import io
import colorama

from nikola import utils
@@ -20,12 +20,15 @@

BASE_URL = "https://themes.getnikola.com/v7/"


def error(msg):
print(colorama.Fore.RED + "ERROR:" + msg)


def theme_list():
return sorted(['base', 'base-jinja', 'bootstrap3', 'bootstrap3-jinja'] + [theme.split('/')[-1] for theme in glob.glob("v7/*")])


def build_theme(theme=None):
if theme is None: # Check them all
print("\nBuilding all themes\n")
@@ -47,9 +50,20 @@ def build_theme(theme=None):
if not os.path.isdir(os.path.join("output", "v7")):
os.mkdir(os.path.join("output", "v7"))

if os.path.isdir('v7/'+theme):
if os.path.isdir('v7/' + theme):
with cd('v7/'):
# If there is a .git file, move it away for a while (Issues #72 and #76)
if os.path.exists(os.path.join(theme, '.git')):
has_tmp = True
tmpdir = tempfile.mkdtemp()
shutil.move(os.path.join(theme, '.git'), os.path.join(tmpdir, 'git-bkp'))
else:
has_tmp = False

subprocess.check_call('zip -r ../output/v7/{0}.zip {0}'.format(theme), stdout=subprocess.PIPE, shell=True)
if has_tmp:
shutil.move(os.path.join(tmpdir, 'git-bkp'), os.path.join(theme, '.git'))
os.rmdir(tmpdir)
subprocess.check_call('capty output/v7/{0}/index.html output/v7/{0}.jpg'.format(theme), stdout=subprocess.PIPE, shell=True)

themes_dict = {}
@@ -81,6 +95,7 @@ def init_theme(theme):
with io.open(conf_path, "a", encoding="utf-8") as conf:
conf.write(u"\n\n{2}\n\nTHEME = '{0}'\n\nUSE_BUNDLES = False\n\nOUTPUT_FOLDER = '{1}'\n\nSOCIAL_BUTTONS_CODE = ''\nUSE_BASE_TAG = False\n".format(theme, o_path, extra_conf))


@contextmanager
def cd(path):
old_dir = os.getcwd()

0 comments on commit 1cca360

Please sign in to comment.
You can’t perform that action at this time.