Skip to content
This repository was archived by the owner on Nov 3, 2020. It is now read-only.

Commit 0b53240

Browse files
committed
Initial commit
0 parents  commit 0b53240

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4281
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.pyc
2+
.DS_Store

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn syte.wsgi -b 0.0.0.0:$PORT

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Syte
2+
3+
A easy to setup and deploy personal site that has social integrations like tumblr, twitter, github and dribble.
4+
5+
6+
## Instructions
7+
8+
TODO!!
9+
10+

manage.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env python
2+
import os
3+
import sys
4+
5+
if __name__ == "__main__":
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "syte.settings")
7+
8+
from django.core.management import execute_from_command_line
9+
10+
execute_from_command_line(sys.argv)

requirements.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Django==1.4
2+
certifi==0.0.8
3+
chardet==1.0.1
4+
httplib2==0.7.4
5+
oauthlib==0.1.3
6+
pyasn1==0.1.3
7+
requests==0.12.1
8+
rsa==3.0.1
9+
wsgiref==0.1.2
10+
psycopg2==2.4.5
11+
gunicorn==0.14.2
12+
-e git://github.com/brosner/python-oauth2.git#egg=oauth2

syte/__init__.py

Whitespace-only changes.

syte/compress.py

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
2+
import os
3+
import sys
4+
import subprocess
5+
import shlex
6+
import traceback
7+
8+
path_to_here = os.path.abspath(os.path.dirname(__file__))
9+
path_before_site = path_to_here[0:path_to_here.rfind('syte')]
10+
sys.path.append(path_before_site)
11+
os.environ['DJANGO_SETTINGS_MODULE'] = 'syte.settings'
12+
13+
from django.conf import settings
14+
15+
def compress_statics():
16+
compress_styles()
17+
compress_js()
18+
19+
def compress_styles():
20+
less_path = 'static/less/styles.less'
21+
css_path = 'static/css/'
22+
23+
try:
24+
subprocess.check_call(shlex.split('lessc {0} {1}styles-{2}.min.css -yui-compress'
25+
.format(less_path, css_path, settings.COMPRESS_REVISION_NUMBER)))
26+
print 'CSS Styles Generated: styles-{0}.min.css'.format(settings.COMPRESS_REVISION_NUMBER)
27+
except Exception:
28+
exc_type, exc_value, exc_traceback = sys.exc_info()
29+
stack_trace = traceback.format_exception(exc_type, exc_value, exc_traceback)
30+
print stack_trace
31+
32+
def compress_js():
33+
js_files = [
34+
'libs/jquery.url.js',
35+
'libs/require.js',
36+
'libs/handlebars.js',
37+
'libs/moment.min.js',
38+
'libs/bootstrap-modal.js',
39+
'libs/spin.min.js',
40+
41+
'components/base.js',
42+
'components/mobile.js',
43+
'components/blog-posts.js',
44+
'components/links.js',
45+
]
46+
47+
if settings.TWITTER_INTEGRATION_ENABLED:
48+
js_files.append('components/twitter.js')
49+
50+
if settings.GITHUB_INTEGRATION_ENABLED:
51+
js_files.append('components/github.js')
52+
53+
if settings.DRIBBBLE_INTEGRATION_ENABLED:
54+
js_files.append('components/dribbble.js')
55+
56+
combined = ''
57+
for js in js_files:
58+
f = open('static/js/' + js, 'r')
59+
combined += f.read()
60+
f.close()
61+
62+
f = open('static/js/combined.js', 'w')
63+
f.write(combined)
64+
f.close()
65+
66+
try:
67+
subprocess.check_call(shlex.split('uglifyjs -o static/js/min/scripts-{0}.min.js static/js/combined.js'.format(settings.COMPRESS_REVISION_NUMBER)))
68+
subprocess.check_call(shlex.split('rm -f static/js/combined.js'))
69+
print 'JavaScript Combined and Minified: scripts-{0}.min.js'.format(settings.COMPRESS_REVISION_NUMBER)
70+
except Exception:
71+
exc_type, exc_value, exc_traceback = sys.exc_info()
72+
stack_trace = traceback.format_exception(exc_type, exc_value, exc_traceback)
73+
print stack_trace
74+
75+
if __name__ == "__main__":
76+
compress_statics()
77+
sys.exit()

syte/context_processor.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
from django.conf import settings
3+
4+
def site_pages(request):
5+
context = dict()
6+
if settings.DEPLOYMENT_MODE == 'dev':
7+
context['DEV_DEPLOYMENT_MODE'] = True
8+
9+
context['COMPRESS_REVISION_NUMBER'] = settings.COMPRESS_REVISION_NUMBER
10+
context['MEDIA_URL'] = settings.MEDIA_URL
11+
12+
context['TWITTER_INTEGRATION_ENABLED'] = settings.TWITTER_INTEGRATION_ENABLED
13+
context['GITHUB_INTEGRATION_ENABLED'] = settings.GITHUB_INTEGRATION_ENABLED
14+
context['DRIBBBLE_INTEGRATION_ENABLED'] = settings.DRIBBBLE_INTEGRATION_ENABLED
15+
16+
return context

syte/settings.py

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Django settings for syte project.
2+
3+
import os
4+
import django
5+
# calculated paths for django and the site
6+
# used as starting points for various other paths
7+
DJANGO_ROOT = os.path.dirname(os.path.realpath(django.__file__))
8+
SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
9+
10+
DEBUG = True
11+
TEMPLATE_DEBUG = DEBUG
12+
13+
ADMINS = (
14+
# ('Your Name', '[email protected]'),
15+
)
16+
MANAGERS = ADMINS
17+
18+
19+
TIME_ZONE = 'America/Chicago'
20+
LANGUAGE_CODE = 'en-us'
21+
SITE_ID = 1
22+
USE_I18N = False
23+
USE_L10N = False
24+
USE_TZ = True
25+
26+
MEDIA_ROOT = os.path.join(SITE_ROOT, 'static')
27+
28+
SECRET_KEY = '5c^pml#7e3d$zor%*_7y098(l0i=d3$+y_((11-_j0&f9rw9%)'
29+
30+
TEMPLATE_LOADERS = (
31+
'django.template.loaders.filesystem.Loader',
32+
'django.template.loaders.app_directories.Loader',
33+
)
34+
35+
MIDDLEWARE_CLASSES = (
36+
'django.middleware.common.CommonMiddleware',
37+
'django.contrib.sessions.middleware.SessionMiddleware',
38+
'django.middleware.csrf.CsrfViewMiddleware',
39+
'django.contrib.messages.middleware.MessageMiddleware',
40+
)
41+
42+
ROOT_URLCONF = 'syte.urls'
43+
44+
WSGI_APPLICATION = 'syte.wsgi.application'
45+
46+
TEMPLATE_DIRS = (
47+
os.path.join(SITE_ROOT, 'templates')
48+
)
49+
50+
TEMPLATE_CONTEXT_PROCESSORS = (
51+
"django.core.context_processors.debug",
52+
"django.core.context_processors.media",
53+
"django.core.context_processors.request",
54+
"django.contrib.messages.context_processors.messages",
55+
"syte.context_processor.site_pages",
56+
)
57+
58+
INSTALLED_APPS = (
59+
'django.contrib.contenttypes',
60+
'django.contrib.sessions',
61+
'django.contrib.sites',
62+
'django.contrib.messages',
63+
'gunicorn',
64+
)
65+
66+
from syte_settings import *

syte/static/imgs/b.png

8.46 KB
Loading

syte/static/imgs/favicon.ico

5.15 KB
Binary file not shown.

syte/static/imgs/ico-comments.png

2.93 KB
Loading

syte/static/imgs/ico-forks.png

2.98 KB
Loading

syte/static/imgs/ico-likes.png

2.93 KB
Loading

syte/static/imgs/ico-watchers.png

3 KB
Loading

syte/static/imgs/pic.png

16.1 KB
Loading

syte/static/js/components/base.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//Global configs and functions shared between js
2+
3+
function numberWithCommas(x) {
4+
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
5+
}
6+
7+
require.config({
8+
baseUrl: "/static/",
9+
paths: {
10+
"text": "js/libs/text",
11+
"json": "js/libs/json"
12+
},
13+
waitSeconds: 15
14+
});
15+
16+
var spin_opts = {
17+
lines: 9,
18+
length: 5,
19+
width: 2,
20+
radius: 4,
21+
rotate: 9,
22+
color: '#4c4c4c',
23+
speed: 1.5,
24+
trail: 40,
25+
shadow: false,
26+
hwaccel: false,
27+
className: 'spinner',
28+
zIndex: 2e9
29+
};
30+
31+
32+
+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
2+
function fetchBlogPosts() {
3+
require(["json!/blog.json", "text!templates/blog-post.html" ],
4+
function(blog_posts, post_template) {
5+
var template = Handlebars.compile(post_template);
6+
7+
$('.loading').remove();
8+
$.each(blog_posts.response.posts, function(i, p) {
9+
p.formated_date = moment(p.date).format('MMMM DD, YYYY')
10+
$('#blog-posts').append(template(p));
11+
});
12+
13+
setupLinks();
14+
setTimeout(setupBlogHeaderCells, 1000);
15+
adjustSelection('home-link');
16+
});
17+
}
18+
19+
function setupBlogHeaderCells() {
20+
21+
if(isMobileView)
22+
return;
23+
24+
var previousTarget,
25+
activeTarget,
26+
$window = $(window),
27+
offsets = [],
28+
targets = [],
29+
$posts = $('.blog-section article hgroup h3 a').each(function() {
30+
if (this.hash) {
31+
targets.push(this.hash);
32+
offsets.push($(this.hash).offset().top);
33+
}
34+
});
35+
36+
function processScroll(e) {
37+
var scrollTop = $window.scrollTop(),
38+
i = offsets.length;
39+
40+
for (i; i--;) {
41+
if (activeTarget != targets[i] && scrollTop > offsets[i] && (!offsets[i + 1] || scrollTop < offsets[i + 1])) {
42+
//set current target to be absolute
43+
$("h3 a[href=" + activeTarget + "]").removeClass("active").css({
44+
position: "absolute",
45+
top: "auto"
46+
});
47+
48+
//set new target to be fixed
49+
activeTarget = targets[i];
50+
$("h3 a[href=" + activeTarget + "]").attr('style', '').addClass("active");
51+
}
52+
53+
if (activeTarget && activeTarget != targets[i] && scrollTop + 50 >= offsets[i] && (!offsets[i + 1] || scrollTop + 50 <= offsets[i + 1])) {
54+
// if it's close to the new target scroll the current target up
55+
$("h3 a[href=" + activeTarget + "]")
56+
.removeClass("active")
57+
.css({
58+
position: "absolute",
59+
top: $(activeTarget).outerHeight(true) + $(activeTarget).offset().top + 90 + "px",
60+
bottom: "auto"
61+
});
62+
}
63+
64+
if (activeTarget == targets[i] && scrollTop > offsets[i] - 50 && (!offsets[i + 1] || scrollTop <= offsets[i + 1] - 50)) {
65+
// if the current target is not fixed make it fixed.
66+
if (!$("h3 a[href=" + activeTarget + "]").hasClass("active")) {
67+
$("h3 a[href=" + activeTarget + "]").attr('style', '').addClass("active");
68+
}
69+
}
70+
}
71+
}
72+
73+
$posts.click(function(e) {
74+
if (!this.hash)
75+
return;
76+
$('html, body').stop().animate({
77+
scrollTop: $(this.hash).offset().top
78+
}, 500, 'linear');
79+
80+
processScroll();
81+
e.preventDefault();
82+
});
83+
84+
$window.scroll(processScroll).trigger("scroll");
85+
}

syte/static/js/components/dribbble.js

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
function setupDribbble(url, el) {
3+
var href = el.href;
4+
5+
if ($('#dribbble-profile').length > 0) {
6+
window.location = href;
7+
return;
8+
}
9+
10+
var params = url.attr('path').split('/').filter(function(w) {
11+
if (w.length)
12+
return true;
13+
return false;
14+
})
15+
16+
if (params.length == 1) {
17+
var username = params[0];
18+
19+
var spinner = new Spinner(spin_opts).spin();
20+
$('#dribbble-link').append(spinner.el);
21+
22+
require(["json!/dribbble/" + username, "text!templates/dribbble-view.html"],
23+
function(dribbble_data, dribbble_view) {
24+
if (dribbble_data.message || dribbble_data.length == 0) {
25+
window.location = href;
26+
return;
27+
}
28+
29+
var template = Handlebars.compile(dribbble_view);
30+
31+
var user = dribbble_data.shots[0].player;
32+
user.following_count = numberWithCommas(user.following_count);
33+
user.followers_count = numberWithCommas(user.followers_count);
34+
user.likes_count = numberWithCommas(user.likes_count);
35+
36+
var template_data = {
37+
"user": user,
38+
"shots": dribbble_data.shots
39+
}
40+
41+
$(template(template_data)).modal().on('hidden', function () {
42+
$(this).remove();
43+
adjustSelection('home-link');
44+
})
45+
46+
spinner.stop();
47+
});
48+
49+
return;
50+
}
51+
52+
window.location = href;
53+
}

0 commit comments

Comments
 (0)