Created
August 12, 2012 19:56
-
-
Save xraymemory/3334074 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # /etc/apache2/sites-available/default | |
| <VirtualHost *:80> | |
| ServerAdmin webmaster@localhost | |
| ServerName default | |
| DocumentRoot /var/www | |
| <Directory /> | |
| Options FollowSymLinks | |
| AllowOverride None | |
| </Directory> | |
| <Directory /var/www/> | |
| Options Indexes FollowSymLinks MultiViews | |
| AllowOverride None | |
| Order allow,deny | |
| allow from all | |
| </Directory> | |
| ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ | |
| <Directory "/usr/lib/cgi-bin"> | |
| AllowOverride None | |
| Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch | |
| Order allow,deny | |
| Allow from all | |
| </Directory> | |
| ErrorLog ${APACHE_LOG_DIR}/error.log | |
| # Possible values include: debug, info, notice, warn, error, crit, | |
| # alert, emerg. | |
| LogLevel warn | |
| CustomLog ${APACHE_LOG_DIR}/access.log combined | |
| Alias /doc/ "/usr/share/doc/" | |
| <Directory "/usr/share/doc/"> | |
| Options Indexes MultiViews FollowSymLinks | |
| AllowOverride None | |
| Order deny,allow | |
| Deny from all | |
| Allow from 127.0.0.0/255.0.0.0 ::1/128 | |
| </Directory> | |
| </VirtualHost> |
This file contains hidden or 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
| #/var/www/micromtn/logr.py | |
| import os | |
| from os import listdir | |
| from flask import Flask, render_template | |
| from flaskext.markdown import Markdown | |
| from utils import list_articles, slugify | |
| logr = Flask(__name__) | |
| logr.config.from_object('config') | |
| logr.config['ARTICLES'] = list_articles() | |
| Markdown(logr) | |
| ARTICLE_DIR = logr.config['ARTICLE_DIR'] | |
| PAGES_DIR = logr.config['PAGES_DIR'] | |
| ARTICLES = logr.config['ARTICLES'] | |
| EXTENSIONS = logr.config['EXTENSIONS'] | |
| @logr.route('/') | |
| def index(): | |
| """ | |
| Render a template to hold the front page blurb. | |
| """ | |
| with open(os.path.join(PAGES_DIR, 'FrontPage.md'), 'r') as f: | |
| blurb = f.read().decode('utf8') | |
| return render_template('index.html', articles=ARTICLES, blurb=blurb) | |
| @logr.route('/code') | |
| def code(): | |
| with open(os.path.join(PAGES_DIR, 'code.md'), 'r') as f: | |
| code = f.read().decode('utf8') | |
| return render_template('code.html', code=code) | |
| @logr.route('/resume') | |
| def resume(): | |
| with open(os.path.join(PAGES_DIR, 'resume.md'), 'r') as f: | |
| resume = f.read().decode('utf8') | |
| return render_template('resume.html', resume=resume) | |
| @logr.route('/b/<slug>', methods=['GET']) | |
| def show(slug): | |
| """ | |
| Search the `articles` directory for an article whose slug matches the URL | |
| parameter. When we find the article, render it. | |
| """ | |
| # Find the right article | |
| for file_ in listdir(ARTICLE_DIR): | |
| if file_.endswith(EXTENSIONS): | |
| with open(os.path.join(ARTICLE_DIR, file_), 'r') as f: | |
| if slug == slugify(f.readline()): | |
| article = os.path.join(ARTICLE_DIR, file_) | |
| break | |
| # Now that we've found the right article, let's process it. | |
| with open(article, 'r') as f: | |
| lines = f.read().split('\n') | |
| # We don't need title or category, but it's easier to explicitly state | |
| # why we're popping the first two lines. | |
| title = lines.pop(0).strip() # Title should appear on the first line | |
| category = lines.pop(0).strip() # Category should appear on the second | |
| source = '\n'.join(lines).decode('utf8') | |
| return render_template('show.html', article=dict(source=source)) | |
| if __name__ == '__main__': | |
| logr.run() |
This file contains hidden or 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
| #/var/www/micromtn/micromtn.wsgi | |
| import sys | |
| sys.path.insert(0, '/var/www/micromtn') | |
| # where logr = Flask(__name__) | |
| from logr import logr as micromtn |
This file contains hidden or 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
| /etc/apache2/sites-available/tangents.co | |
| <VirtualHost *:80> | |
| WSGIDaemonProcess micromtn | |
| WSGIScriptAlias / /var/www/micromtn/micromtn.wsgi | |
| <Directory /var/www/micromtn> | |
| WSGIProcessGroup micromtn | |
| WSGIApplicationGroup %{GLOBAL} | |
| Order deny,allow | |
| Allow from all | |
| </Directory> | |
| </VirtualHost> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment