Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rigoneri committed May 27, 2012
0 parents commit 0b53240
Show file tree
Hide file tree
Showing 54 changed files with 4,281 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc
.DS_Store
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn syte.wsgi -b 0.0.0.0:$PORT
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Syte

A easy to setup and deploy personal site that has social integrations like tumblr, twitter, github and dribble.


## Instructions

TODO!!


10 changes: 10 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys

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

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
12 changes: 12 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Django==1.4
certifi==0.0.8
chardet==1.0.1
httplib2==0.7.4
oauthlib==0.1.3
pyasn1==0.1.3
requests==0.12.1
rsa==3.0.1
wsgiref==0.1.2
psycopg2==2.4.5
gunicorn==0.14.2
-e git://github.com/brosner/python-oauth2.git#egg=oauth2
Empty file added syte/__init__.py
Empty file.
77 changes: 77 additions & 0 deletions syte/compress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

import os
import sys
import subprocess
import shlex
import traceback

path_to_here = os.path.abspath(os.path.dirname(__file__))
path_before_site = path_to_here[0:path_to_here.rfind('syte')]
sys.path.append(path_before_site)
os.environ['DJANGO_SETTINGS_MODULE'] = 'syte.settings'

from django.conf import settings

def compress_statics():
compress_styles()
compress_js()

def compress_styles():
less_path = 'static/less/styles.less'
css_path = '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',

'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')

combined = ''
for js in js_files:
f = open('static/js/' + js, 'r')
combined += f.read()
f.close()

f = open('static/js/combined.js', 'w')
f.write(combined)
f.close()

try:
subprocess.check_call(shlex.split('uglifyjs -o static/js/min/scripts-{0}.min.js static/js/combined.js'.format(settings.COMPRESS_REVISION_NUMBER)))
subprocess.check_call(shlex.split('rm -f 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()
16 changes: 16 additions & 0 deletions syte/context_processor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

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['TWITTER_INTEGRATION_ENABLED'] = settings.TWITTER_INTEGRATION_ENABLED
context['GITHUB_INTEGRATION_ENABLED'] = settings.GITHUB_INTEGRATION_ENABLED
context['DRIBBBLE_INTEGRATION_ENABLED'] = settings.DRIBBBLE_INTEGRATION_ENABLED

return context
66 changes: 66 additions & 0 deletions syte/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# 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', 'your_email@example.com'),
)
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.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',
)

from syte_settings import *
Binary file added syte/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 syte/static/imgs/favicon.ico
Binary file not shown.
Binary file added syte/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 syte/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 syte/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 syte/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 syte/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.
32 changes: 32 additions & 0 deletions syte/static/js/components/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//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
};



85 changes: 85 additions & 0 deletions syte/static/js/components/blog-posts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

function fetchBlogPosts() {
require(["json!/blog.json", "text!templates/blog-post.html" ],
function(blog_posts, post_template) {
var template = Handlebars.compile(post_template);

$('.loading').remove();
$.each(blog_posts.response.posts, function(i, p) {
p.formated_date = moment(p.date).format('MMMM DD, YYYY')
$('#blog-posts').append(template(p));
});

setupLinks();
setTimeout(setupBlogHeaderCells, 1000);
adjustSelection('home-link');
});
}

function setupBlogHeaderCells() {

if(isMobileView)
return;

var previousTarget,
activeTarget,
$window = $(window),
offsets = [],
targets = [],
$posts = $('.blog-section article hgroup h3 a').each(function() {
if (this.hash) {
targets.push(this.hash);
offsets.push($(this.hash).offset().top);
}
});

function processScroll(e) {
var scrollTop = $window.scrollTop(),
i = offsets.length;

for (i; i--;) {
if (activeTarget != targets[i] && scrollTop > offsets[i] && (!offsets[i + 1] || scrollTop < offsets[i + 1])) {
//set current target to be absolute
$("h3 a[href=" + activeTarget + "]").removeClass("active").css({
position: "absolute",
top: "auto"
});

//set new target to be fixed
activeTarget = targets[i];
$("h3 a[href=" + activeTarget + "]").attr('style', '').addClass("active");
}

if (activeTarget && activeTarget != targets[i] && scrollTop + 50 >= offsets[i] && (!offsets[i + 1] || scrollTop + 50 <= offsets[i + 1])) {
// if it's close to the new target scroll the current target up
$("h3 a[href=" + activeTarget + "]")
.removeClass("active")
.css({
position: "absolute",
top: $(activeTarget).outerHeight(true) + $(activeTarget).offset().top + 90 + "px",
bottom: "auto"
});
}

if (activeTarget == targets[i] && scrollTop > offsets[i] - 50 && (!offsets[i + 1] || scrollTop <= offsets[i + 1] - 50)) {
// if the current target is not fixed make it fixed.
if (!$("h3 a[href=" + activeTarget + "]").hasClass("active")) {
$("h3 a[href=" + activeTarget + "]").attr('style', '').addClass("active");
}
}
}
}

$posts.click(function(e) {
if (!this.hash)
return;
$('html, body').stop().animate({
scrollTop: $(this.hash).offset().top
}, 500, 'linear');

processScroll();
e.preventDefault();
});

$window.scroll(processScroll).trigger("scroll");
}
53 changes: 53 additions & 0 deletions syte/static/js/components/dribbble.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

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

if ($('#dribbble-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();
$('#dribbble-link').append(spinner.el);

require(["json!/dribbble/" + username, "text!templates/dribbble-view.html"],
function(dribbble_data, dribbble_view) {
if (dribbble_data.message || dribbble_data.length == 0) {
window.location = href;
return;
}

var template = Handlebars.compile(dribbble_view);

var user = dribbble_data.shots[0].player;
user.following_count = numberWithCommas(user.following_count);
user.followers_count = numberWithCommas(user.followers_count);
user.likes_count = numberWithCommas(user.likes_count);

var template_data = {
"user": user,
"shots": dribbble_data.shots
}

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

spinner.stop();
});

return;
}

window.location = href;
}
Loading

0 comments on commit 0b53240

Please sign in to comment.