├── data └── .gitkeep ├── libs └── .gitkeep ├── blog ├── __init__.py ├── blueprints │ ├── __init__.py │ ├── admin │ │ ├── __init__.py │ │ ├── models.py │ │ ├── views.py │ │ └── templates │ │ │ └── login.html │ ├── apis │ │ ├── __init__.py │ │ └── views.py │ └── posts │ │ ├── __init__.py │ │ ├── templates │ │ ├── new.html │ │ ├── nicEditor.html │ │ ├── comment.html │ │ ├── list_posts_for_editing.html │ │ ├── editor.html │ │ ├── edit.html │ │ ├── list_posts.html │ │ ├── _paginate.html │ │ └── detail.html │ │ ├── models.py │ │ └── views.py ├── templates │ ├── tags.html │ ├── autocomplete.html │ ├── slide.html │ └── base.html ├── manager.py ├── settings.py ├── main.py └── utilities.py ├── .openshift ├── cron │ ├── daily │ │ └── .gitignore │ ├── hourly │ │ ├── .gitignore │ │ └── heatcache │ ├── minutely │ │ └── .gitignore │ ├── monthly │ │ └── .gitignore │ ├── weekly │ │ ├── chrono.dat │ │ ├── chronograph │ │ ├── jobs.deny │ │ ├── jobs.allow │ │ └── README │ └── README.cron ├── action_hooks │ ├── post_deploy │ ├── deploy │ ├── pre_build │ ├── build │ ├── post_start_python-2.6 │ ├── post_stop_python-2.6 │ ├── pre_start_python-2.6 │ └── pre_stop_python-2.6 └── markers │ └── README ├── wsgi ├── static │ ├── images │ │ ├── .gitkeeper │ │ ├── alipay.png │ │ ├── bg_tags.gif │ │ ├── pengfei.jpg │ │ ├── sina_32x32.png │ │ ├── douban_32x32.png │ │ ├── ui-anim_basic_16x16.gif │ │ ├── glyphicons-halflings.png │ │ ├── ui-bg_glass_75_dadada_1x400.png │ │ └── horn.svg │ ├── css │ │ ├── highlight │ │ │ ├── pojoaque.jpg │ │ │ ├── school_book.png │ │ │ ├── brown_papersq.png │ │ │ ├── ascetic.css │ │ │ ├── tomorrow.css │ │ │ ├── solarized_dark.css │ │ │ ├── solarized_light.css │ │ │ ├── tomorrow-night-bright.css │ │ │ ├── tomorrow-night-eighties.css │ │ │ ├── tomorrow-night.css │ │ │ ├── tomorrow-night-blue.css │ │ │ ├── vs.css │ │ │ ├── ir_black.css │ │ │ ├── pojoaque.css │ │ │ ├── dark.css │ │ │ ├── rainbow.css │ │ │ ├── brown_paper.css │ │ │ ├── github.css │ │ │ ├── idea.css │ │ │ ├── far.css │ │ │ ├── monokai.css │ │ │ ├── zenburn.css │ │ │ ├── magula.css │ │ │ ├── school_book.css │ │ │ ├── googlecode.css │ │ │ ├── default.css │ │ │ ├── sunburst.css │ │ │ ├── xcode.css │ │ │ └── arta.css │ │ ├── blog.css │ │ ├── bootstrap │ │ │ └── bootstrap-responsive.css │ │ └── jquery-ui.css │ ├── README │ └── js │ │ ├── bootstrap-button.js │ │ ├── bootstrap-carousel.js │ │ └── highlight.pack.js ├── .htaccess └── application ├── .gitignore ├── box ├── uwsgi.ini ├── application.py └── nginx.conf ├── setup.py └── README /data/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /blog/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /blog/blueprints/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.openshift/cron/daily/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.openshift/cron/hourly/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /blog/blueprints/admin/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /blog/blueprints/apis/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /blog/blueprints/posts/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /wsgi/static/images/.gitkeeper: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.openshift/cron/minutely/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.openshift/cron/monthly/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.pyo 3 | *.swp 4 | -------------------------------------------------------------------------------- /.openshift/cron/weekly/chrono.dat: -------------------------------------------------------------------------------- 1 | Time And Relative D...n In Execution (Open)Shift! 2 | -------------------------------------------------------------------------------- /.openshift/cron/hourly/heatcache: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | curl -I https://life-map.rhcloud.com/apis/cnbeta.json 4 | -------------------------------------------------------------------------------- /.openshift/cron/weekly/chronograph: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "`date`: `cat $(dirname \"$0\")/chrono.dat`" 4 | -------------------------------------------------------------------------------- /wsgi/static/images/alipay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coldfire-x/openshift-flask-mongdb/HEAD/wsgi/static/images/alipay.png -------------------------------------------------------------------------------- /wsgi/static/images/bg_tags.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coldfire-x/openshift-flask-mongdb/HEAD/wsgi/static/images/bg_tags.gif -------------------------------------------------------------------------------- /wsgi/static/images/pengfei.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coldfire-x/openshift-flask-mongdb/HEAD/wsgi/static/images/pengfei.jpg -------------------------------------------------------------------------------- /wsgi/static/images/sina_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coldfire-x/openshift-flask-mongdb/HEAD/wsgi/static/images/sina_32x32.png -------------------------------------------------------------------------------- /wsgi/static/images/douban_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coldfire-x/openshift-flask-mongdb/HEAD/wsgi/static/images/douban_32x32.png -------------------------------------------------------------------------------- /wsgi/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine on 2 | 3 | RewriteCond %{HTTP:X-Forwarded-Proto} !https 4 | RewriteRule .* https://%{HTTP_HOST}%{REQUEST} [R,L] 5 | -------------------------------------------------------------------------------- /wsgi/static/css/highlight/pojoaque.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coldfire-x/openshift-flask-mongdb/HEAD/wsgi/static/css/highlight/pojoaque.jpg -------------------------------------------------------------------------------- /wsgi/static/css/highlight/school_book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coldfire-x/openshift-flask-mongdb/HEAD/wsgi/static/css/highlight/school_book.png -------------------------------------------------------------------------------- /wsgi/static/images/ui-anim_basic_16x16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coldfire-x/openshift-flask-mongdb/HEAD/wsgi/static/images/ui-anim_basic_16x16.gif -------------------------------------------------------------------------------- /wsgi/static/css/highlight/brown_papersq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coldfire-x/openshift-flask-mongdb/HEAD/wsgi/static/css/highlight/brown_papersq.png -------------------------------------------------------------------------------- /wsgi/static/images/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coldfire-x/openshift-flask-mongdb/HEAD/wsgi/static/images/glyphicons-halflings.png -------------------------------------------------------------------------------- /wsgi/static/images/ui-bg_glass_75_dadada_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coldfire-x/openshift-flask-mongdb/HEAD/wsgi/static/images/ui-bg_glass_75_dadada_1x400.png -------------------------------------------------------------------------------- /.openshift/cron/weekly/jobs.deny: -------------------------------------------------------------------------------- 1 | # 2 | # Any script or job files listed in here (one entry per line) will NOT be 3 | # executed (read as ignored by run-parts). 4 | # 5 | 6 | README 7 | 8 | -------------------------------------------------------------------------------- /.openshift/action_hooks/post_deploy: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This is a simple post deploy hook executed after your application 3 | # is deployed and started. This script gets executed directly, so 4 | # it could be python, php, ruby, etc. -------------------------------------------------------------------------------- /.openshift/action_hooks/deploy: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This deploy hook gets executed after dependencies are resolved and the 3 | # build hook has been run but before the application has been started back 4 | # up again. This script gets executed directly, so it could be python, php, 5 | # ruby, etc. 6 | -------------------------------------------------------------------------------- /.openshift/action_hooks/pre_build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This is a simple script and will be executed on your CI system if 3 | # available. Otherwise it will execute while your application is stopped 4 | # before the build step. This script gets executed directly, so it 5 | # could be python, php, ruby, etc. -------------------------------------------------------------------------------- /.openshift/action_hooks/build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This is a simple build script and will be executed on your CI system if 3 | # available. Otherwise it will execute while your application is stopped 4 | # before the deploy step. This script gets executed directly, so it 5 | # could be python, php, ruby, etc. -------------------------------------------------------------------------------- /blog/templates/tags.html: -------------------------------------------------------------------------------- 1 | {% if tags %} 2 |
12 | {% endif %} 13 | -------------------------------------------------------------------------------- /.openshift/markers/README: -------------------------------------------------------------------------------- 1 | Markers 2 | =========== 3 | 4 | Adding marker files to this directory will have the following effects: 5 | 6 | force_clean_build - Will remove the python virtualenv and force rebuild it 7 | including any previously downloaded libraries 8 | 9 | hot_deploy - Enables the dynamic reloading of python scripts via WSGI Daemon 10 | mode. 11 | -------------------------------------------------------------------------------- /box/uwsgi.ini: -------------------------------------------------------------------------------- 1 | [uwsgi] 2 | socket=127.0.0.1:8000 3 | master=true 4 | processes=2 5 | 6 | protocol = uwsgi 7 | touch-reload = /tmp/uwsgi_reload.txt 8 | daemonize = /tmp/uwsgi.log 9 | pidfile = /tmp/uwsgi.pid 10 | 11 | virtualenv = /Users/pengphy/Codes/virtualenvs/virtenv 12 | pythonpath = /Users/pengphy/Codes/virtualenvs/virtenv/life 13 | 14 | chdir = /Users/pengphy/Codes/virtualenvs/virtenv/life/box 15 | module = application 16 | callable = app 17 | -------------------------------------------------------------------------------- /blog/manager.py: -------------------------------------------------------------------------------- 1 | import sys, os 2 | sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 3 | 4 | from flask.ext.script import Manager, Server 5 | from main import app 6 | 7 | manager = Manager(app) 8 | 9 | # Turn on debugger by default and reloader 10 | manager.add_command("runserver", Server( 11 | use_debugger = True, 12 | use_reloader = True, 13 | host = '0.0.0.0') 14 | ) 15 | 16 | if __name__ == "__main__": 17 | manager.run() 18 | -------------------------------------------------------------------------------- /.openshift/cron/weekly/jobs.allow: -------------------------------------------------------------------------------- 1 | # 2 | # Script or job files listed in here (one entry per line) will be 3 | # executed on a weekly-basis. 4 | # 5 | # Example: The chronograph script will be executed weekly but the README 6 | # and chrono.dat files in this directory will be ignored. 7 | # 8 | # The README file is actually ignored due to the entry in the 9 | # jobs.deny which is checked before jobs.allow (this file). 10 | # 11 | chronograph 12 | 13 | -------------------------------------------------------------------------------- /box/application.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import os 3 | import sys 4 | 5 | sys.path.append(os.path.join(os.environ['OPENSHIFT_REPO_DIR'], 'blog')) 6 | 7 | virtenv = os.environ['APPDIR'] + '/virtenv/' 8 | os.environ['PYTHON_EGG_CACHE'] = os.path.join(virtenv, 'lib/python2.6/site-packages') 9 | virtualenv = os.path.join(virtenv, 'bin/activate_this.py') 10 | try: 11 | execfile(virtualenv, dict(__file__=virtualenv)) 12 | except IOError: 13 | pass 14 | 15 | from main import app 16 | -------------------------------------------------------------------------------- /wsgi/application: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import os 3 | import sys 4 | 5 | sys.path.append(os.path.join(os.environ['OPENSHIFT_REPO_DIR'], 'blog')) 6 | 7 | virtenv = os.environ['APPDIR'] + '/virtenv/' 8 | os.environ['PYTHON_EGG_CACHE'] = os.path.join(virtenv, 'lib/python2.6/site-packages') 9 | virtualenv = os.path.join(virtenv, 'bin/activate_this.py') 10 | try: 11 | execfile(virtualenv, dict(__file__=virtualenv)) 12 | except IOError: 13 | pass 14 | 15 | from main import app as application 16 | -------------------------------------------------------------------------------- /wsgi/static/README: -------------------------------------------------------------------------------- 1 | Public, static content goes here. Users can create rewrite rules to link to 2 | content in the static dir. For example, django commonly uses /media/ 3 | directories for static content. For example in a .htaccess file in a 4 | wsgi/.htaccess location, developers could put: 5 | 6 | RewriteEngine On 7 | RewriteRule ^application/media/(.+)$ /static/media/$1 [L] 8 | 9 | Then copy the media/* content to yourapp/wsgi/static/media/ and it should 10 | just work. 11 | 12 | Note: The ^application/ part of the URI match is required. 13 | -------------------------------------------------------------------------------- /blog/blueprints/posts/templates/new.html: -------------------------------------------------------------------------------- 1 | {% import "editor.html" as forms %} 2 | {% extends "base.html" %} 3 | 4 | {% block css_header %} 5 | 6 | 7 | {% endblock %} 8 | 9 | {% block sidebar %} 10 | 11 | {% endblock %} 12 | 13 | {% block content %} 14 | {{ forms.render(form) }} 15 | {% endblock %} 16 | 17 | {% block js_footer %} 18 | 19 | {% endblock %} 20 | -------------------------------------------------------------------------------- /blog/settings.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | # debug 4 | DEBUG = os.environ.get('FLASK_DEBUG', False) 5 | 6 | # mongodb configuration 7 | MONGODB_DB = os.environ['OPENSHIFT_APP_NAME'] 8 | MONGODB_USERNAME = os.environ['OPENSHIFT_MONGODB_DB_USERNAME'] 9 | MONGODB_PASSWORD = os.environ['OPENSHIFT_MONGODB_DB_PASSWORD'] 10 | MONGODB_HOST = os.environ['OPENSHIFT_MONGODB_DB_HOST'] 11 | MONGODB_PORT = os.environ['OPENSHIFT_MONGODB_DB_PORT'] 12 | 13 | # secret keys 14 | SECRET_KEY = '=5NO>NO>a"Tj4=^#~Co^T#fD_b!-&J' 15 | 16 | # cache timeout, 30 mins 17 | CACHE_TIMEOUT = 60 * 30 18 | 19 | # PERMANENT_SESSION_LIFETIME 20 | PERMANENT_SESSION_LIFETIME = 60 * 60 * 15 21 | -------------------------------------------------------------------------------- /blog/blueprints/admin/models.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from main import db 4 | 5 | class Users(db.Document): 6 | username = db.StringField(required=True) 7 | password = db.StringField(required=True) 8 | first_name = db.StringField(max_length=50) 9 | last_name = db.StringField(max_length=50) 10 | 11 | @classmethod 12 | def check_user_passwd(cls, username, password): 13 | is_valid = None 14 | 15 | try: 16 | Users.objects.get(username=username, password=password) 17 | except Users.DoesNotExist: 18 | is_valid = False 19 | else: 20 | is_valid = True 21 | 22 | return is_valid 23 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup(name='life-map', 4 | version='1.0', 5 | description='blog for pengfei xue', 6 | author='Pengfei Xue', 7 | author_email='pengphy@gmail.com', 8 | url='https://facebook.com/pengfei.xue', 9 | install_requires=['flask==0.9', 10 | 'mongoengine==0.7.6', 11 | 'flask-mongoengine==0.6', 12 | 'Flask-Script==0.5.1', 13 | 'Flask-WTF==0.8', 14 | 'WTForms==1.0.2', 15 | 'pymongo==2.3', 16 | 'Jinja2==2.6', 17 | 'WTForms==1.0.2', 18 | 'Werkzeug==0.8.3', 19 | 'argparse==1.2.1', 20 | 'feedparser==5.1.3', 21 | ], 22 | ) 23 | -------------------------------------------------------------------------------- /.openshift/action_hooks/post_start_python-2.6: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # The pre_start_cartridge and pre_stop_cartridge hooks are *SOURCED* 4 | # immediately before (re)starting or stopping the specified cartridge. 5 | # They are able to make any desired environment variable changes as 6 | # well as other adjustments to the application environment. 7 | 8 | # The post_start_cartridge and post_stop_cartridge hooks are executed 9 | # immediately after (re)starting or stopping the specified cartridge. 10 | 11 | # Exercise caution when adding commands to these hooks. They can 12 | # prevent your application from stopping cleanly or starting at all. 13 | # Application start and stop is subject to different timeouts 14 | # throughout the system. 15 | -------------------------------------------------------------------------------- /.openshift/action_hooks/post_stop_python-2.6: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # The pre_start_cartridge and pre_stop_cartridge hooks are *SOURCED* 4 | # immediately before (re)starting or stopping the specified cartridge. 5 | # They are able to make any desired environment variable changes as 6 | # well as other adjustments to the application environment. 7 | 8 | # The post_start_cartridge and post_stop_cartridge hooks are executed 9 | # immediately after (re)starting or stopping the specified cartridge. 10 | 11 | # Exercise caution when adding commands to these hooks. They can 12 | # prevent your application from stopping cleanly or starting at all. 13 | # Application start and stop is subject to different timeouts 14 | # throughout the system. 15 | -------------------------------------------------------------------------------- /.openshift/action_hooks/pre_start_python-2.6: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # The pre_start_cartridge and pre_stop_cartridge hooks are *SOURCED* 4 | # immediately before (re)starting or stopping the specified cartridge. 5 | # They are able to make any desired environment variable changes as 6 | # well as other adjustments to the application environment. 7 | 8 | # The post_start_cartridge and post_stop_cartridge hooks are executed 9 | # immediately after (re)starting or stopping the specified cartridge. 10 | 11 | # Exercise caution when adding commands to these hooks. They can 12 | # prevent your application from stopping cleanly or starting at all. 13 | # Application start and stop is subject to different timeouts 14 | # throughout the system. 15 | -------------------------------------------------------------------------------- /.openshift/action_hooks/pre_stop_python-2.6: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # The pre_start_cartridge and pre_stop_cartridge hooks are *SOURCED* 4 | # immediately before (re)starting or stopping the specified cartridge. 5 | # They are able to make any desired environment variable changes as 6 | # well as other adjustments to the application environment. 7 | 8 | # The post_start_cartridge and post_stop_cartridge hooks are executed 9 | # immediately after (re)starting or stopping the specified cartridge. 10 | 11 | # Exercise caution when adding commands to these hooks. They can 12 | # prevent your application from stopping cleanly or starting at all. 13 | # Application start and stop is subject to different timeouts 14 | # throughout the system. 15 | -------------------------------------------------------------------------------- /blog/blueprints/posts/templates/nicEditor.html: -------------------------------------------------------------------------------- 1 | {% block css_header %} 2 | 3 | {% endblock %} 4 | 5 | {% macro nicEditor() -%} 6 | 10 | 11 | 12 | 17 | 18 | 19 | 20 | 21 | 22 | {%- endmacro %} 23 | -------------------------------------------------------------------------------- /blog/templates/autocomplete.html: -------------------------------------------------------------------------------- 1 | {% macro autocomplete(elem_id, minlenght_in=1) -%} 2 | 21 | {%- endmacro %} 22 | -------------------------------------------------------------------------------- /.openshift/cron/weekly/README: -------------------------------------------------------------------------------- 1 | Run scripts or jobs on a weekly basis 2 | ===================================== 3 | Any scripts or jobs added to this directory will be run on a scheduled basis 4 | (weekly) using run-parts. 5 | 6 | run-parts ignores any files that are hidden or dotfiles (.*) or backup 7 | files (*~ or *,) or named *.{rpmsave,rpmorig,rpmnew,swp,cfsaved} and handles 8 | the files named jobs.deny and jobs.allow specially. 9 | 10 | In this specific example, the chronograph script is the only script or job file 11 | executed on a weekly basis (due to white-listing it in jobs.allow). And the 12 | README and chrono.dat file are ignored either as a result of being black-listed 13 | in jobs.deny or because they are NOT white-listed in the jobs.allow file. 14 | 15 | For more details, please see ../README.cron file. 16 | 17 | -------------------------------------------------------------------------------- /blog/blueprints/posts/templates/comment.html: -------------------------------------------------------------------------------- 1 | {% macro render(form) -%} 2 | 29 | {% endmacro %} 30 | -------------------------------------------------------------------------------- /blog/blueprints/posts/templates/list_posts_for_editing.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block sidebar %} 4 | 5 | {% endblock %} 6 | 7 | {% block content %} 8 || Title | 11 |Created | 12 |Actions | 13 | 14 | 15 | 16 | {% for post in posts %} 17 |
|---|---|---|
| {{ post.title }} | 19 |{{ post.created_at.strftime('%Y-%m-%d') }} | 20 |Edit | 21 |
{{ post.body | striptags | truncate(100) }}
9 |10 | {{ post.created_at.strftime('%Y-%m-%d %H:%M') }} | 11 | {% with total=post.comments|length %} 12 | {{ total }} comment {%- if total > 1 %}s{%- endif -%} 13 | {% endwith %} 14 |
15 |{{ post.body | safe }}
20 |
{{ comment.body }}
44 |{{ comment.author }} on {{ comment.created_at.strftime('%H:%M %Y-%m-%d') }}
45 | {{ comment.text }} 46 | {% endfor %} 47 | {% endif %} 48 |
39 |