-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e261804
Showing
118 changed files
with
10,821 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.html linguist-language=Python |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
A community framework based on Django. | ||
|
||
~ requirement | ||
|
||
Python & Django & PIL(optional). | ||
|
||
~ runtime | ||
|
||
All environments, such as VPS or Heroku. | ||
|
||
~ database | ||
|
||
SQLite, PostgreSQL, MySQL, DB2 or other relational databases. | ||
|
||
~ installation([Demo](http://hulu.im)) | ||
|
||
1. Install [Python](https://www.python.org) and [Django](https://www.djangoproject.com); | ||
|
||
2. Download [Hulu](https://github.com/lostab/hulu.git), and decompress to anywhere; | ||
|
||
3. Run `python runserver.py` and enjoy it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env python | ||
# coding: utf-8 | ||
import os | ||
import sys | ||
|
||
reload(sys) | ||
sys.setdefaultencoding('utf8') | ||
|
||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hulu.settings") | ||
|
||
from django.core.wsgi import get_wsgi_application | ||
application = get_wsgi_application() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from django.http import HttpResponse | ||
import json | ||
|
||
def jsonp(request, content): | ||
if request.GET.get('callback'): | ||
callback = request.GET.get('callback').strip() | ||
return HttpResponse(callback + '(' + json.dumps(content, encoding='utf-8', ensure_ascii=False, indent=4) + ')', content_type="application/json; charset=utf-8") | ||
else: | ||
return HttpResponse(json.dumps(content, encoding='utf-8', ensure_ascii=False, indent=4), content_type="application/json; charset=utf-8") | ||
|
||
def resetdb(): | ||
from django.db import connection | ||
try: | ||
conn = connection.cursor() | ||
except OperationalError: | ||
connected = False | ||
connection.close() | ||
else: | ||
connected = True | ||
|
||
def checkmodule(module): | ||
import imp | ||
try: | ||
imp.find_module(module) | ||
return True | ||
except ImportError: | ||
return False |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,265 @@ | ||
# Django settings for hulu project. | ||
|
||
import os | ||
|
||
DEBUG = False | ||
#TEMPLATE_DEBUG = DEBUG | ||
|
||
ADMINS = ( | ||
# ('Your Name', '[email protected]'), | ||
) | ||
|
||
MANAGERS = ADMINS | ||
|
||
DATABASES = { | ||
'default': { | ||
|
||
|
||
'ENGINE': 'django.db.backends.mysql', | ||
'NAME': 'hulu', # | ||
'USER': 'root', # | ||
'PASSWORD': '1416520104', # | ||
'HOST': '127.0.0.1', #IP | ||
'PORT': '5555', # | ||
|
||
|
||
|
||
} | ||
|
||
} | ||
|
||
#import dj_database_url | ||
#DATABASES['default'] = dj_database_url.config() | ||
|
||
if 'postgresql_user' in os.environ: | ||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.postgresql', | ||
'NAME': os.environ['postgresql_db'], | ||
'USER': os.environ['postgresql_user'], | ||
'PASSWORD': os.environ['postgresql_pass'], | ||
'HOST': '127.0.0.1', | ||
'PORT': '', | ||
} | ||
} | ||
|
||
if 'VCAP_SERVICES' in os.environ: | ||
import json | ||
vcap = json.loads(os.environ['VCAP_SERVICES']) | ||
if 'sqldb' in vcap: | ||
sqldb = vcap['sqldb'][0]['credentials'] | ||
DATABASES = { | ||
'default': { | ||
'ENGINE' : 'ibm_db_django', | ||
'NAME' : str(sqldb['db']), | ||
'USER' : str(sqldb['username']), | ||
'PASSWORD' : str(sqldb['password']), | ||
'HOST' : str(sqldb['host']), | ||
'PORT' : str(sqldb['port']), | ||
'PCONNECT' : True, | ||
'CONN_MAX_AGE' : None, | ||
} | ||
} | ||
if 'elephantsql' in vcap: | ||
import dj_database_url | ||
DATABASES['default'] = dj_database_url.config() | ||
'''if 'cloudantNoSQLDB' in vcap: | ||
import cloudant | ||
nosqldb = vcap['cloudantNoSQLDB'][0]['credentials'] | ||
USERNAME = str(nosqldb['username']) | ||
PASSWORD = str(nosqldb['password']) | ||
account = cloudant.Account(USERNAME, async=True) | ||
# login, so we can make changes | ||
login = account.login(USERNAME, PASSWORD) | ||
assert login.status_code == 200''' | ||
|
||
CACHES = { | ||
'default': { | ||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', | ||
'LOCATION': '' | ||
} | ||
} | ||
|
||
# Hosts/domain names that are valid for this site; required if DEBUG is False | ||
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts | ||
ALLOWED_HOSTS = ['*'] | ||
|
||
# Local time zone for this installation. Choices can be found here: | ||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name | ||
# although not all choices may be available on all operating systems. | ||
# In a Windows environment this must be set to your system time zone. | ||
#TIME_ZONE = 'America/Chicago' | ||
TIME_ZONE = 'Asia/Shanghai' | ||
|
||
# Language code for this installation. All choices can be found here: | ||
# http://www.i18nguy.com/unicode/language-identifiers.html | ||
LANGUAGE_CODE = 'en-us' | ||
|
||
SITE_ID = 1 | ||
|
||
# If you set this to False, Django will make some optimizations so as not | ||
# to load the internationalization machinery. | ||
USE_I18N = True | ||
|
||
# If you set this to False, Django will not format dates, numbers and | ||
# calendars according to the current locale. | ||
USE_L10N = True | ||
|
||
# If you set this to False, Django will not use timezone-aware datetimes. | ||
USE_TZ = True | ||
|
||
# Absolute filesystem path to the directory that will hold user-uploaded files. | ||
# Example: "/var/www/example.com/media/" | ||
#MEDIA_ROOT = '' | ||
MEDIA_ROOT = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'static') | ||
|
||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a | ||
# trailing slash. | ||
# Examples: "http://example.com/media/", "http://media.example.com/" | ||
MEDIA_URL = '/f/' | ||
|
||
# Absolute path to the directory static files should be collected to. | ||
# Don't put anything in this directory yourself; store your static files | ||
# in apps' "static/" subdirectories and in STATICFILES_DIRS. | ||
# Example: "/var/www/example.com/static/" | ||
#STATIC_ROOT = '' | ||
STATIC_ROOT = 'staticfiles' | ||
|
||
# URL prefix for static files. | ||
# Example: "http://example.com/static/", "http://static.example.com/" | ||
STATIC_URL = '/s/' | ||
|
||
# Additional locations of static files | ||
STATICFILES_DIRS = ( | ||
# Put strings here, like "/home/html/static" or "C:/www/django/static". | ||
# Always use forward slashes, even on Windows. | ||
# Don't forget to use absolute paths, not relative paths. | ||
|
||
os.path.join(os.path.dirname(os.path.dirname(__file__)), 'static'), | ||
) | ||
|
||
# List of finder classes that know how to find static files in | ||
# various locations. | ||
STATICFILES_FINDERS = ( | ||
'django.contrib.staticfiles.finders.FileSystemFinder', | ||
'django.contrib.staticfiles.finders.AppDirectoriesFinder', | ||
# 'django.contrib.staticfiles.finders.DefaultStorageFinder', | ||
) | ||
|
||
# Make this unique, and don't share it with anybody. | ||
SECRET_KEY = 'g0$co#vn8%5f^$v9=x09t)&t67+ij=3%b^cj@f(t2c^%ua4yut' | ||
|
||
# List of callables that know how to import templates from various sources. | ||
#TEMPLATE_LOADERS = ( | ||
# 'django.template.loaders.filesystem.Loader', | ||
# 'django.template.loaders.app_directories.Loader', | ||
# 'django.template.loaders.eggs.Loader', | ||
#) | ||
|
||
MIDDLEWARE_CLASSES = ( | ||
'django.middleware.common.CommonMiddleware', | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
'django.middleware.csrf.CsrfViewMiddleware', | ||
'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
'django.contrib.messages.middleware.MessageMiddleware', | ||
# Uncomment the next line for simple clickjacking protection: | ||
# 'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
'django.middleware.locale.LocaleMiddleware', | ||
'django.middleware.gzip.GZipMiddleware', | ||
) | ||
|
||
ROOT_URLCONF = 'hulu.urls' | ||
|
||
# Python dotted path to the WSGI application used by Django's runserver. | ||
WSGI_APPLICATION = 'hulu.wsgi.application' | ||
|
||
TEMPLATE_DIRS = ( | ||
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". | ||
# Always use forward slashes, even on Windows. | ||
# Don't forget to use absolute paths, not relative paths. | ||
|
||
os.path.join(os.path.dirname(os.path.dirname(__file__)), 'tpl'), | ||
) | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': [ | ||
os.path.join(os.path.dirname(os.path.dirname(__file__)), 'tpl'), | ||
], | ||
'APP_DIRS': True, | ||
'OPTIONS': { | ||
'context_processors': [ | ||
"django.contrib.auth.context_processors.auth", | ||
'django.template.context_processors.request', | ||
] | ||
}, | ||
}, | ||
] | ||
|
||
INSTALLED_APPS = ( | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.sites', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
'django.contrib.admin', | ||
# Uncomment the next line to enable the admin: | ||
# 'django.contrib.admin', | ||
# Uncomment the next line to enable admin documentation: | ||
# 'django.contrib.admindocs', | ||
'user', | ||
'item', | ||
'tag', | ||
) | ||
|
||
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer' | ||
|
||
# A sample logging configuration. The only tangible logging | ||
# performed by this configuration is to send an email to | ||
# the site admins on every HTTP 500 error when DEBUG=False. | ||
# See http://docs.djangoproject.com/en/dev/topics/logging for | ||
# more details on how to customize your logging configuration. | ||
LOGGING = { | ||
'version': 1, | ||
'disable_existing_loggers': False, | ||
'filters': { | ||
'require_debug_false': { | ||
'()': 'django.utils.log.RequireDebugFalse' | ||
} | ||
}, | ||
'handlers': { | ||
'mail_admins': { | ||
'level': 'ERROR', | ||
'filters': ['require_debug_false'], | ||
'class': 'django.utils.log.AdminEmailHandler' | ||
} | ||
}, | ||
'loggers': { | ||
'django.request': { | ||
'handlers': ['mail_admins'], | ||
'level': 'ERROR', | ||
'propagate': True, | ||
}, | ||
} | ||
} | ||
|
||
#TEMPLATE_CONTEXT_PROCESSORS = ( | ||
# 'django.contrib.auth.context_processors.auth', | ||
# 'django.core.context_processors.request', | ||
# 'django.core.context_processors.i18n', | ||
#) | ||
|
||
TEST_RUNNER = 'django.test.runner.DiscoverRunner' | ||
|
||
LOGIN_URL = '/u/login/' | ||
LOGIN_REDIRECT_URL = '/u/' | ||
LOGOUT_URL = '/u/logout/' | ||
|
||
EMAIL_HOST = 'smtp.gmail.com' | ||
EMAIL_PORT = 587 | ||
EMAIL_USE_TLS = True | ||
if 'system_mail_username' in os.environ and 'system_mail_password' in os.environ: | ||
EMAIL_HOST_USER = os.environ['system_mail_username'] | ||
EMAIL_HOST_PASSWORD = os.environ['system_mail_password'] |
Binary file not shown.
Oops, something went wrong.