Commits

Panayiotis Lipiridis  committed fac813d Merge

Merged with gae-init

  • Participants
  • Parent commits 79556d1, 2034635

Comments (0)

Files changed (7)

File Gruntfile.coffee

 module.exports = (grunt) ->
+  require('load-grunt-tasks') grunt
   path = require 'path'
 
   grunt.initConfig
       min: 'main/static/min'
       dst: 'main/static/dst'
 
-    grunt.loadNpmTasks 'grunt-bower-task'
-    grunt.loadNpmTasks 'grunt-contrib-clean'
-    grunt.loadNpmTasks 'grunt-contrib-watch'
     grunt.registerTask 'default', ['watch']
     grunt.registerTask 'ext', ['clean:ext', 'bower']

File main/__init__.py

 
 """
 
-__version__ = '0.16.5'
+__version__ = '0.16.7'

File main/admin.py

   announcement_html = wtf.TextAreaField('Announcement HTML', filters=[util.strip_filter])
   announcement_type = wtf.SelectField('Announcement Type', choices=[(t, t.title()) for t in model.Config.announcement_type._choices])
   brand_name = wtf.StringField('Brand Name', [wtf.validators.required()], filters=[util.strip_filter])
-  facebook_app_id = wtf.StringField('Facebook App ID', filters=[util.strip_filter])
-  facebook_app_secret = wtf.StringField('Facebook App Secret', filters=[util.strip_filter])
+  facebook_app_id = wtf.StringField('App ID', filters=[util.strip_filter])
+  facebook_app_secret = wtf.StringField('App Secret', filters=[util.strip_filter])
   feedback_email = wtf.StringField('Feedback Email', [wtf.validators.optional(), wtf.validators.email()], filters=[util.email_filter])
   flask_secret_key = wtf.StringField('Secret Key', [wtf.validators.optional()], filters=[util.strip_filter])
   notify_on_new_user = wtf.BooleanField('Send an email notification when a user signs up')
-  twitter_consumer_key = wtf.StringField('Twitter Consumer Key', filters=[util.strip_filter])
-  twitter_consumer_secret = wtf.StringField('Twitter Consumer Secret', filters=[util.strip_filter])
+  twitter_consumer_key = wtf.StringField('Consumer Key', filters=[util.strip_filter])
+  twitter_consumer_secret = wtf.StringField('Consumer Secret', filters=[util.strip_filter])
 
 
 @auth.admin_required

File main/templates/admin/bit/google_analytics_tracking_id.html

       'Google Analytics',
       (form.analytics_id,),
       form.analytics_id.data,
+      '''
+        Get it from
+        <a href="https://www.google.com/analytics/web/" target="_blank">Google Analytics</a>
+      '''
     )
 }}

File main/util.py

 # coding: utf-8
 
 from datetime import datetime
+from datetime import date
 from uuid import uuid4
 import re
 import unicodedata
 
 
 def json_value(value):
-  if isinstance(value, datetime):
+  if isinstance(value, datetime) or isinstance(value, date):
     return value.isoformat()
   if isinstance(value, ndb.Key):
     return value.urlsafe()

File package.json

     "grunt-bower-task": "~0",
     "grunt-cli": "~0",
     "grunt-contrib-clean": "~0",
-    "grunt-contrib-watch": "~0"
+    "grunt-contrib-watch": "~0",
+    "load-grunt-tasks": "~0"
   }
 }
 DIR_LIB = os.path.join(DIR_MAIN, 'lib')
 DIR_LIBX = os.path.join(DIR_MAIN, 'libx')
 FILE_LIB = '%s.zip' % DIR_LIB
-FILE_LIB_REQUIREMENTS = 'requirements.txt'
-FILE_PIP_RUN = os.path.join(DIR_TEMP, 'pip.guard')
+FILE_REQUIREMENTS = 'requirements.txt'
+FILE_BOWER = 'bower.json'
+FILE_PACKAGE = 'package.json'
+FILE_PIP_GUARD = os.path.join(DIR_TEMP, 'pip.guard')
+FILE_NPM_GUARD = os.path.join(DIR_TEMP, 'npm.guard')
+FILE_BOWER_GUARD = os.path.join(DIR_TEMP, 'bower.guard')
 
 DIR_BIN = os.path.join(DIR_NODE_MODULES, '.bin')
 FILE_COFFEE = os.path.join(DIR_BIN, 'coffee')
 
 
 def check_pip_should_run():
-  if not os.path.exists(FILE_PIP_RUN):
+  if not os.path.exists(FILE_PIP_GUARD):
     return True
-  return os.path.getmtime(FILE_PIP_RUN) < \
-      os.path.getmtime(FILE_LIB_REQUIREMENTS)
+  return os.path.getmtime(FILE_PIP_GUARD) < \
+      os.path.getmtime(FILE_REQUIREMENTS)
+
+
+def check_npm_should_run():
+  if not os.path.exists(FILE_NPM_GUARD):
+    return True
+  return os.path.getmtime(FILE_NPM_GUARD) < os.path.getmtime(FILE_PACKAGE)
+
+
+def check_bower_should_run():
+  if not os.path.exists(FILE_BOWER_GUARD):
+    return True
+  return os.path.getmtime(FILE_BOWER_GUARD) < os.path.getmtime(FILE_BOWER)
 
 
 def install_py_libs():
   if not check_pip_should_run():
     return
 
-  exec_pip_commands('pip install -q -r %s' % FILE_LIB_REQUIREMENTS)
+  exec_pip_commands('pip install -q -r %s' % FILE_REQUIREMENTS)
 
   exclude_ext = ['.pth', '.pyc', '.egg-info', '.dist-info']
   exclude_prefix = ['setuptools-', 'pip-', 'Pillow-']
     copy = shutil.copy if os.path.isfile(src_path) else shutil.copytree
     copy(src_path, _get_dest(dir_))
 
-  with open(FILE_PIP_RUN, 'w') as pip_run:
-    pip_run.write('Prevents pip execution if newer than requirements.txt')
+  with open(FILE_PIP_GUARD, 'w') as pip_guard:
+    pip_guard.write('Prevents pip execution if newer than requirements.txt')
 
 
 def clean_py_libs():
   remove_file_dir(DIR_VENV)
 
 
-def get_dependencies(file_name):
-  with open(file_name) as json_file:
-    json_data = json.load(json_file)
-  dependencies = json_data.get('dependencies', dict()).keys()
-  return dependencies + json_data.get('devDependencies', dict()).keys()
+def install_dependencies():
+  make_dirs(DIR_TEMP)
+  if check_npm_should_run():
+    with open(FILE_NPM_GUARD, 'w') as npm_guard:
+      npm_guard.write('Prevents npm execution if newer than package.json')
+    os.system('npm install')
 
-
-def install_dependencies():
-  for dependency in get_dependencies('package.json'):
-    if not os.path.exists(os.path.join(DIR_NODE_MODULES, dependency)):
-      os.system('npm install')
-      break
-
-  for dependency in get_dependencies('bower.json'):
-    if not os.path.exists(os.path.join(DIR_BOWER_COMPONENTS, dependency)):
-      os.system('"%s" ext' % FILE_GRUNT)
-      break
+  if check_bower_should_run():
+    with open(FILE_BOWER_GUARD, 'w') as bower_guard:
+      bower_guard.write('Prevents bower execution if newer than bower.json')
+    os.system('"%s" ext' % FILE_GRUNT)
 
   install_py_libs()
 
         urllib.urlencode({'version': main.__version__}),
       )
     response = urllib2.urlopen(request)
-    make_dirs(DIR_TEMP)
     with open(FILE_UPDATE, 'w') as update_json:
       update_json.write(response.read())
   except urllib2.HTTPError:
 
 
 def find_gae_path():
-  if platform.system() == 'Windows':
+  is_windows = platform.system() == 'Windows'
+  if is_windows:
     gae_path = None
     for path in os.environ['PATH'].split(os.pathsep):
       if os.path.isfile(os.path.join(path, 'dev_appserver.py')):
       gae_path = os.path.dirname(os.path.realpath(gae_path))
   if not gae_path:
     return ''
-  if not os.path.isfile(os.path.join(gae_path, 'gcloud')):
+  gcloud_exec = 'gcloud.cmd' if is_windows else 'gcloud'
+  if not os.path.isfile(os.path.join(gae_path, gcloud_exec)):
     return gae_path
   gae_path = os.path.join(gae_path, '..', 'platform', 'google_appengine')
   if os.path.exists:
   clean_py_libs()
   clean_files()
   remove_file_dir(FILE_LIB)
-  remove_file_dir(FILE_PIP_RUN)
+  remove_file_dir(FILE_PIP_GUARD)
+  remove_file_dir(FILE_NPM_GUARD)
+  remove_file_dir(FILE_BOWER_GUARD)
 
 
 def run_minify():