Skip to content

Commit

Permalink
update from source
Browse files Browse the repository at this point in the history
update from source
  • Loading branch information
kiddomk committed Sep 9, 2012
1 parent d5c56b2 commit fbcc2ee
Show file tree
Hide file tree
Showing 78 changed files with 1,502 additions and 393 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.pyc
.DS_Store
personal_syte_settings.py
24 changes: 24 additions & 0 deletions DESIGN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- All JS behavior is kicked off by the call to fetchBlogPosts() (syte/static/js/components/blog-posts.js)

- This function is added with JQuery after page finishes loading.

- fetchBlogPosts() handles:

- Setting up the handlebars template 'environment', etc.
- Then calls setupLinks()

- setupLinks() is main entry point for the supported services

- This attaches behavior to the click event of all 'a' tags.
- Each click event will determine if it's a link for one of the supported
services.
- If the click is for a supported service:

- All other service modal dialogs are hidden and the setup* function
for the specified service is called.

- The setup* function for the service is in charge of:

- Querying server-side endpoint for the service and populating
handlebar.js context with json returned.
- Rendering template for service with handlebar.js
21 changes: 21 additions & 0 deletions HELP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Basic steps to add support for a particular service:

1. Add information to
[README](https://github.com/rigoneri/syte/blob/master/README.md)
2. Add setting to turn service on/off
in [syte_settings.py](https://github.com/rigoneri/syte/blob/master/syte/syte_settings.py)
3. Add above setting to site_pages context processor in
[context_processor.py](https://github.com/rigoneri/syte/blob/master/syte/context_processor.py)
4. Add a new django view for the particular service to get info and return json.
- For example [twitter.py](https://github.com/rigoneri/syte/blob/master/syte/views/twitter.py) or [dribbble.py](https://github.com/rigoneri/syte/blob/master/syte/views/dribbble.py)
5. Add above view to [urls.py](https://github.com/rigoneri/syte/blob/master/syte/urls.py)
6. Write js file/function to query django view and add to
[js components](https://github.com/rigoneri/syte/tree/master/syte/static/js/components)
7. Add hook/call to main javascript integration point
[links.js](https://github.com/rigoneri/syte/tree/master/syte/static/js/components/links.js)
8. Add above js to list of js to
[compress.py](https://github.com/rigoneri/syte/blob/master/syte/compress.py)
9. Add link for service to
[base view template](https://github.com/rigoneri/syte/blob/master/syte/templates/base.html)
10. Add html template to
[templates directory](https://github.com/rigoneri/syte/tree/master/syte/static/templates) to be rendered js file/function that queries django view for service.
230 changes: 187 additions & 43 deletions README.md

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
List of services to add integration for:

- Twitter [DONE]
- Github [DONE]
- Dribbble [DONE]
- Instagram [DONE]
- Tumblr [DONE]
- Wordpress
- Facebook
- Foursquare [DONE]
- LinkedIn
- Youtube
- Netflix
- Flickr
- Picasa
- Last.fm [DONE]
- Rdio
- Spotify
- Soundcloud [DONE]
- Etsy
- Fitbit
- Bitbucket [DONE]

List taken from [Syte's Unexpected Traction and Numbers](http://rigoneri.com/post/25804668500)
4 changes: 3 additions & 1 deletion manage.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
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)
execute_from_command_line(sys.argv)
Binary file added readme-imgs/allydimg.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 readme-imgs/amastys.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 readme-imgs/ameswarb.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 readme-imgs/bhashkar.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 readme-imgs/bronskiy.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 readme-imgs/chriskun.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 readme-imgs/clayferris.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 readme-imgs/damilare.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 readme-imgs/danielcampo.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 readme-imgs/dannycochran.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 readme-imgs/darrenmowat.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 readme-imgs/deni.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 readme-imgs/dmragone.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 readme-imgs/eventh.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 readme-imgs/f-6.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 readme-imgs/f-7.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 readme-imgs/f-8.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 readme-imgs/f-9.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 readme-imgs/hussfelt.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 readme-imgs/jeff-tchang.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 readme-imgs/jeiting.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 readme-imgs/jihonrado.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 readme-imgs/lfranchi.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 readme-imgs/lukelee.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 readme-imgs/pranayairan.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 readme-imgs/sheetsj.png
Binary file added readme-imgs/srir.png
8 changes: 6 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
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
<<<<<<< HEAD
-e git://github.com/brosner/python-oauth2.git#egg=oauth2
pybars==0.0.1
pybars==0.0.1
=======
pybars==0.0.1
rauth==0.4.14
>>>>>>> upstream/master
79 changes: 50 additions & 29 deletions syte/compress.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@

#!/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__))
path_before_site = path_to_here[0:path_to_here.rfind('syte')]
sys.path.append(path_before_site)
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:
#This won't work on windows.
subprocess.check_call(shlex.split('mkdir -p static/css static/js/min'))
except Exception:
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 = 'static/less/styles.less'
css_path = 'static/css/'
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'
Expand All @@ -35,20 +41,21 @@ def compress_styles():
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',
'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:
Expand All @@ -66,25 +73,39 @@ def compress_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')

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

f = open('static/js/combined.js', 'w')
f.write(combined)
f.close()
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 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'))
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()
7 changes: 6 additions & 1 deletion syte/context_processor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

# -*- coding: utf-8 -*-
from django.conf import settings


def site_pages(request):
context = dict()
if settings.DEPLOYMENT_MODE == 'dev':
Expand All @@ -16,6 +17,10 @@ def site_pages(request):
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['DISQUS_INTEGRATION_ENABLED'] = settings.DISQUS_INTEGRATION_ENABLED
context['DISQUS_SHORTNAME'] = settings.DISQUS_SHORTNAME
Expand Down
8 changes: 6 additions & 2 deletions syte/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Django settings for syte project.

import os
Expand Down Expand Up @@ -33,6 +34,7 @@
)

MIDDLEWARE_CLASSES = (
'django.middleware.gzip.GZipMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand Down Expand Up @@ -63,5 +65,7 @@
'gunicorn',
)

from syte_settings import *

try:
from personal_syte_settings import *
except ImportError:
from syte_settings import *
Binary file modified syte/static/imgs/b.png
Binary file modified syte/static/imgs/ico-comments.png
Binary file modified syte/static/imgs/ico-forks.png
Binary file modified syte/static/imgs/ico-likes.png
Binary file modified syte/static/imgs/ico-watchers.png
3 changes: 0 additions & 3 deletions syte/static/js/components/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,3 @@ var spin_opts = {
className: 'spinner',
zIndex: 2e9
};



45 changes: 45 additions & 0 deletions syte/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;
}
8 changes: 4 additions & 4 deletions syte/static/js/components/blog-posts.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

function fetchBlogPosts(tag) {
var blog_fetch_url = '/blog.json';
function fetchBlogPosts(offset, tag) {
var blog_fetch_url = '/blog.json?o=' + offset;

if (tag)
blog_fetch_url = '/tags/' + tag;
blog_fetch_url = '/tags/' + tag + '/?o=' + offset;

$.getJSON(blog_fetch_url, function(blog_posts) {
require(["text!templates/blog-post-text.html",
Expand Down Expand Up @@ -50,7 +50,7 @@ function fetchBlogPosts(tag) {
adjustBlogHeaders();
prettyPrint();
setTimeout(setupBlogHeaderScroll, 1000);
adjustSelection('home-link');
adjustSelection('home');

$('body').trigger("blog-post-loaded");
});
Expand Down
2 changes: 1 addition & 1 deletion syte/static/js/components/dribbble.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function setupDribbble(url, el) {

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

spinner.stop();
Expand Down
Loading

0 comments on commit fbcc2ee

Please sign in to comment.