Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
kiddomk committed Dec 4, 2012
2 parents 31633bf + d3cceb6 commit e622a75
Show file tree
Hide file tree
Showing 106 changed files with 6,154 additions and 2 deletions.
Empty file added __init__.py
Empty file.
Binary file added __init__.pyc
Binary file not shown.
114 changes: 114 additions & 0 deletions compress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import subprocess
import shlex
import traceback

PATH_TO_HERE = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.join(PATH_TO_HERE, '..'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'syte.settings'

from django.conf import settings


def compress_statics():
out_paths = (os.path.join(PATH_TO_HERE, 'static/css'),
os.path.join(PATH_TO_HERE, 'static/js/min'))

try:
for path in out_paths:
if not os.path.exists(path):
os.mkdir(path)
except OSError:
print 'Make sure to create "syte > static > css" and "syte > static > js > min" before compressing statics.'

compress_styles()
compress_js()


def compress_styles():
less_path = os.path.join(PATH_TO_HERE, 'static/less/styles.less')
css_path = os.path.join(PATH_TO_HERE, 'static/css/')

try:
subprocess.check_call(shlex.split('lessc {0} {1}styles-{2}.min.css -yui-compress'
.format(less_path, css_path, settings.COMPRESS_REVISION_NUMBER)))
print 'CSS Styles Generated: styles-{0}.min.css'.format(settings.COMPRESS_REVISION_NUMBER)
except Exception:
exc_type, exc_value, exc_traceback = sys.exc_info()
stack_trace = traceback.format_exception(exc_type, exc_value, exc_traceback)
print stack_trace


def compress_js():
js_files = [
'libs/jquery.url.js',
'libs/require.js',
'libs/handlebars.js',
'libs/moment.min.js',
'libs/bootstrap-modal.js',
'libs/spin.min.js',
'libs/prettify.js',

'components/base.js',
'components/mobile.js',
'components/blog-posts.js',
'components/links.js',
]

if settings.TWITTER_INTEGRATION_ENABLED:
js_files.append('components/twitter.js')

if settings.GITHUB_INTEGRATION_ENABLED:
js_files.append('components/github.js')

if settings.DRIBBBLE_INTEGRATION_ENABLED:
js_files.append('components/dribbble.js')

if settings.INSTAGRAM_INTEGRATION_ENABLED:
js_files.append('components/instagram.js')

if settings.DISQUS_INTEGRATION_ENABLED:
js_files.append('components/disqus.js')

if settings.LASTFM_INTEGRATION_ENABLED:
js_files.append('components/lastfm.js')

if settings.SOUNDCLOUD_INTEGRATION_ENABLED:
js_files.append('components/soundcloud.js')

if settings.BITBUCKET_INTEGRATION_ENABLED:
js_files.append('components/bitbucket.js')

if settings.FOURSQUARE_INTEGRATION_ENABLED:
js_files.append('components/foursquare.js')

if settings.TENT_INTEGRATION_ENABLED:
js_files.append('components/tent.js')

combined = ''
for js in js_files:
with open(os.path.join(PATH_TO_HERE, 'static/js/' + js), 'r') as f:
combined += f.read()

with open(os.path.join(PATH_TO_HERE, 'static/js/combined.js'), 'w') as f:
f.write(combined)

try:
subprocess.check_call(shlex.split('uglifyjs -o {0}scripts-{1}.min.js {2}'.format(
os.path.join(PATH_TO_HERE, 'static/js/min/'),
settings.COMPRESS_REVISION_NUMBER,
os.path.join(PATH_TO_HERE, 'static/js/combined.js'))))
os.remove(os.path.join(PATH_TO_HERE, 'static/js/combined.js'))
print 'JavaScript Combined and Minified: scripts-{0}.min.js'.format(settings.COMPRESS_REVISION_NUMBER)
except Exception:
exc_type, exc_value, exc_traceback = sys.exc_info()
stack_trace = traceback.format_exception(exc_type, exc_value, exc_traceback)
print stack_trace


if __name__ == "__main__":
compress_statics()
sys.exit()
38 changes: 38 additions & 0 deletions context_processor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
from django.conf import settings


def site_pages(request):
context = dict()
if settings.DEPLOYMENT_MODE == 'dev':
context['DEV_DEPLOYMENT_MODE'] = True

context['COMPRESS_REVISION_NUMBER'] = settings.COMPRESS_REVISION_NUMBER
context['MEDIA_URL'] = settings.MEDIA_URL

context['RSS_FEED_URL'] = settings.RSS_FEED_URL
context['RSS_FEED_ENABLED'] = settings.RSS_FEED_ENABLED

context['TWITTER_INTEGRATION_ENABLED'] = settings.TWITTER_INTEGRATION_ENABLED
context['GITHUB_INTEGRATION_ENABLED'] = settings.GITHUB_INTEGRATION_ENABLED
context['DRIBBBLE_INTEGRATION_ENABLED'] = settings.DRIBBBLE_INTEGRATION_ENABLED
context['INSTAGRAM_INTEGRATION_ENABLED'] = settings.INSTAGRAM_INTEGRATION_ENABLED
context['BITBUCKET_INTEGRATION_ENABLED'] = settings.BITBUCKET_INTEGRATION_ENABLED
context['LASTFM_INTEGRATION_ENABLED'] = settings.LASTFM_INTEGRATION_ENABLED
context['SOUNDCLOUD_INTEGRATION_ENABLED'] = settings.SOUNDCLOUD_INTEGRATION_ENABLED
context['FOURSQUARE_INTEGRATION_ENABLED'] = settings.FOURSQUARE_INTEGRATION_ENABLED

context['TENT_INTEGRATION_ENABLED'] = settings.TENT_INTEGRATION_ENABLED
context['TENT_ENTITY_URI'] = settings.TENT_ENTITY_URI
context['TENT_FEED_URL'] = settings.TENT_FEED_URL

context['DISQUS_INTEGRATION_ENABLED'] = settings.DISQUS_INTEGRATION_ENABLED
context['DISQUS_SHORTNAME'] = settings.DISQUS_SHORTNAME

context['GOOGLE_ANALYTICS_TRACKING_ID'] = settings.GOOGLE_ANALYTICS_TRACKING_ID

context['WOOPRA_TRACKING_DOMAIN'] = settings.WOOPRA_TRACKING_DOMAIN
context['WOOPRA_TRACKING_IDLE_TIMEOUT'] = settings.WOOPRA_TRACKING_IDLE_TIMEOUT
context['WOOPRA_TRACKING_INCLUDE_QUERY'] = settings.WOOPRA_TRACKING_INCLUDE_QUERY

return context
Binary file added context_processor.pyc
Binary file not shown.
2 changes: 0 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys


if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "syte.settings")

Expand Down
71 changes: 71 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
# Django settings for syte project.

import os
import django
# calculated paths for django and the site
# used as starting points for various other paths
DJANGO_ROOT = os.path.dirname(os.path.realpath(django.__file__))
SITE_ROOT = os.path.dirname(os.path.realpath(__file__))

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', '[email protected]'),
)
MANAGERS = ADMINS


TIME_ZONE = 'America/Chicago'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = False
USE_L10N = False
USE_TZ = True

MEDIA_ROOT = os.path.join(SITE_ROOT, 'static')

SECRET_KEY = '5c^pml#7e3d$zor%*_7y098(l0i=d3$+y_((11-_j0&f9rw9%)'

TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)

MIDDLEWARE_CLASSES = (
'django.middleware.gzip.GZipMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)

ROOT_URLCONF = 'syte.urls'

WSGI_APPLICATION = 'syte.wsgi.application'

TEMPLATE_DIRS = (
os.path.join(SITE_ROOT, 'templates')
)

TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.debug",
"django.core.context_processors.media",
"django.core.context_processors.request",
"django.contrib.messages.context_processors.messages",
"syte.context_processor.site_pages",
)

INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'gunicorn',
)

try:
from personal_syte_settings import *
except ImportError:
from syte_settings import *
Binary file added settings.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions static/css/styles-1.0.min.css

Large diffs are not rendered by default.

Binary file added static/imgs/.DS_Store
Binary file not shown.
Binary file added static/imgs/b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/imgs/favicon.ico
Binary file not shown.
Binary file added static/imgs/ico-comments.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/imgs/ico-forks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/imgs/ico-likes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/imgs/ico-watchers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/imgs/pic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions static/js/components/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//Global configs and functions shared between js

function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

require.config({
baseUrl: "/static/",
paths: {
"text": "js/libs/text",
"json": "js/libs/json"
},
waitSeconds: 15
});

var spin_opts = {
lines: 9,
length: 5,
width: 2,
radius: 4,
rotate: 9,
color: '#4c4c4c',
speed: 1.5,
trail: 40,
shadow: false,
hwaccel: false,
className: 'spinner',
zIndex: 2e9
};
45 changes: 45 additions & 0 deletions static/js/components/bitbucket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

function setupBitbucket(url, el) {
var href = el.href;

if ($('#bitbucket-profile').length > 0) {
window.location = href;
return;
}

var params = url.attr('path').split('/').filter(function(w) {
if (w.length)
return true;
return false;
})

if (params.length == 1) {
var username = params[0];

var spinner = new Spinner(spin_opts).spin();
$('#bitbucket-link').append(spinner.el);

require(["json!/bitbucket/" + username, "text!templates/bitbucket-profile.html"],
function(bitbucket_data, bitbucket_view) {
if (bitbucket_data.error || bitbucket_data.length == 0) {
window.location = href;
return;
}

var template = Handlebars.compile(bitbucket_view);
bitbucket_data.user.followers = numberWithCommas(bitbucket_data.user.followers)

$(template(bitbucket_data)).modal().on('hidden', function () {
$(this).remove();
adjustSelection('home');
})

spinner.stop();

});

return;
}

window.location = href;
}
Loading

0 comments on commit e622a75

Please sign in to comment.