Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Commit

Permalink
demo version initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanpitts committed Jun 6, 2012
1 parent f5bc88d commit 55b8442
Show file tree
Hide file tree
Showing 247 changed files with 18,689 additions and 1 deletion.
25 changes: 25 additions & 0 deletions LICENSE
@@ -0,0 +1,25 @@
Copyright (c) 2011, Mozilla
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright owner nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 2 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,2 @@
recursive-include */*/templates *.*
recursive-include */locale *.*
45 changes: 44 additions & 1 deletion README.md
@@ -1,4 +1,47 @@
source source
====== ======


Code for source.mozillaopennews.org/ Source is a website [dedicated to][sinker-explain] "advocating for, shining a spotlight on, and helping to generate community around the code that's being written in journalism." It's built with [Django][django], using Mozilla's [Playdoh web app template][gh-playdoh].

[sinker-explain]: http://sinker.tumblr.com/post/12203160394/journalism-in-the-open-hard-coding-community
[django]: http://www.djangoproject.com/
[gh-playdoh]: https://github.com/mozilla/playdoh


Installation
------------

### Requirements

You need Python 2.6 or 2.7, Mozilla's [funfactory][funfactory], MySQL, git, virtualenv, and a Unix-like OS.

[funfactory]: https://github.com/mozilla/funfactory

### Setup

First, make sure you've got funfactory installed, because the Playdoh app template will need it.

`pip install funfactory`

Then:

1. Fork and/or clone this Source repository from GitHub
2. Set up a virtual environment for your new project
3. Activate your virtualenv and cd into the project directory
4. Make sure you have all the development requirements

`pip install -r /requirements/dev.txt`

### Configuration

This repository includes a sqlite demo database, with a few articles, people, organizations and code pages in place for you to play with. If you want to switch over to MySQL instead, you'll need to create a new database, adjust the DATABASES dict in source/settings/local.py accordingly, and then

`manage.py syncdb`

Or just leave things pointing to the sqlite demo database for a quick peek. Either way, it's time to fire it up!

`manage.py runserver`

And you should be able view your dev server at [http://localhost:8000/][localhost]

[localhost]: http://localhost:8000/
43 changes: 43 additions & 0 deletions Vagrantfile
@@ -0,0 +1,43 @@
require "yaml"

# Load up our vagrant config files -- vagrantconfig.yaml first
_config = YAML.load(File.open(File.join(File.dirname(__FILE__),
"vagrantconfig.yaml"), File::RDONLY).read)

# Local-specific/not-git-managed config -- vagrantconfig_local.yaml
begin
_config.merge!(YAML.load(File.open(File.join(File.dirname(__FILE__),
"vagrantconfig_local.yaml"), File::RDONLY).read))
rescue Errno::ENOENT # No vagrantconfig_local.yaml found -- that's OK; just
# use the defaults.
end

CONF = _config
MOUNT_POINT = '/home/vagrant/project'

Vagrant::Config.run do |config|
config.vm.box = "lucid32"
config.vm.box_url = "http://files.vagrantup.com/lucid32.box"

config.vm.forward_port 8000, 8000

# Increase vagrant's patience during hang-y CentOS bootup
# see: https://github.com/jedi4ever/veewee/issues/14
config.ssh.max_tries = 50
config.ssh.timeout = 300

# nfs needs to be explicitly enabled to run.
if CONF['nfs'] == false or RUBY_PLATFORM =~ /mswin(32|64)/
config.vm.share_folder("v-root", MOUNT_POINT, ".")
else
config.vm.share_folder("v-root", MOUNT_POINT, ".", :nfs => true)
end

# Add to /etc/hosts: 33.33.33.24 dev.playdoh.org
config.vm.network :hostonly, "33.33.33.24"

config.vm.provision :puppet do |puppet|
puppet.manifests_path = "puppet/manifests"
puppet.manifest_file = "vagrant.pp"
end
end
28 changes: 28 additions & 0 deletions bin/compile-mo.sh
@@ -0,0 +1,28 @@
#!/bin/bash

TARGET=$1
LOCKFILE="/tmp/compile-mo-${2}.lock"

function usage() {
echo "syntax:"
echo " compile-mo.sh locale-dir/ [unique]"
echo "unique is an optional string that will be used as the name of the lockfile"
exit 1
}

# check if file and dir are there
if [[ ($# -gt 2) || (! -d "$TARGET") ]]; then usage; fi

# check if the lockfile exists
if [ -e $LOCKFILE ]; then
echo "$LOCKFILE present, exiting"
exit 99
fi

touch $LOCKFILE
for lang in `find $TARGET -type f -name "*.po"`; do
dir=`dirname $lang`
stem=`basename $lang .po`
msgfmt -o ${dir}/${stem}.mo $lang
done
rm $LOCKFILE
20 changes: 20 additions & 0 deletions bin/crontab/crontab.tpl
@@ -0,0 +1,20 @@
#
# {{ header }}
#

# MAILTO=some-email-list

HOME=/tmp

# Every minute!
* * * * * {{ cron }}

# Every hour.
42 * * * * {{ django }} cleanup

# Every 2 hours.
1 */2 * * * {{ cron }} something

# Etc...

MAILTO=root
42 changes: 42 additions & 0 deletions bin/crontab/gen-crons.py
@@ -0,0 +1,42 @@
#!/usr/bin/env python
import os
from optparse import OptionParser

from jinja2 import Template


HEADER = '!!AUTO-GENERATED!! Edit bin/crontab/crontab.tpl instead.'
TEMPLATE = open(os.path.join(os.path.dirname(__file__), 'crontab.tpl')).read()


def main():
parser = OptionParser()
parser.add_option('-w', '--webapp',
help='Location of web app (required)')
parser.add_option('-u', '--user',
help=('Prefix cron with this user. '
'Only define for cron.d style crontabs.'))
parser.add_option('-p', '--python', default='/usr/bin/python2.6',
help='Python interpreter to use.')

(opts, args) = parser.parse_args()

if not opts.webapp:
parser.error('-w must be defined')

ctx = {'django': 'cd %s; %s manage.py' % (opts.webapp, opts.python)}
ctx['cron'] = '%s cron' % ctx['django']

if opts.user:
for k, v in ctx.iteritems():
ctx[k] = '%s %s' % (opts.user, v)

# Needs to stay below the opts.user injection.
ctx['python'] = opts.python
ctx['header'] = HEADER

print Template(TEMPLATE).render(**ctx)


if __name__ == '__main__':
main()
69 changes: 69 additions & 0 deletions bin/jenkins.sh
@@ -0,0 +1,69 @@
#!/bin/sh
# This script makes sure that Jenkins can properly run your tests against your
# codebase.
set -e

DB_HOST="localhost"
DB_USER="hudson"

cd $WORKSPACE
VENV=$WORKSPACE/venv

echo "Starting build on executor $EXECUTOR_NUMBER..."

# Make sure there's no old pyc files around.
find . -name '*.pyc' -exec rm {} \;

if [ ! -d "$VENV/bin" ]; then
echo "No virtualenv found. Making one..."
virtualenv $VENV --no-site-packages
source $VENV/bin/activate
pip install --upgrade pip
pip install coverage
fi

git submodule sync -q
git submodule update --init --recursive

if [ ! -d "$WORKSPACE/vendor" ]; then
echo "No /vendor... crap."
exit 1
fi

source $VENV/bin/activate
pip install -q -r requirements/compiled.txt
pip install -q -r requirements/dev.txt

cat > settings/local.py <<SETTINGS
from settings.base import *
ROOT_URLCONF = 'workspace.urls'
LOG_LEVEL = logging.ERROR
# Database name has to be set because of sphinx
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '${DB_HOST}',
'NAME': '${JOB_NAME}',
'USER': 'hudson',
'PASSWORD': '',
'OPTIONS': {'init_command': 'SET storage_engine=InnoDB'},
'TEST_NAME': 'test_${JOB_NAME}',
'TEST_CHARSET': 'utf8',
'TEST_COLLATION': 'utf8_general_ci',
}
}
INSTALLED_APPS += ('django_nose',)
CELERY_ALWAYS_EAGER = True
SETTINGS

echo "Creating database if we need it..."
echo "CREATE DATABASE IF NOT EXISTS ${JOB_NAME}"|mysql -u $DB_USER -h $DB_HOST

echo "Starting tests..."
export FORCE_DB=1
coverage run manage.py test --noinput --with-xunit
coverage xml $(find apps lib -name '*.py')

echo "FIN"
14 changes: 14 additions & 0 deletions bin/update/commander_settings.py-dist
@@ -0,0 +1,14 @@
SRC_DIR = ''
WWW_DIR = ''

CRON_NAME = ''

DEPLOY_SCRIPT = ''
REMOTE_UPDATE_SCRIPT = ''

WEB_HOSTGROUP = ''
CELERY_HOSTGROUP = ''
CELERY_SERVICE = ''

UPDATE_REF = 'origin/master'
SSH_KEY = None

0 comments on commit 55b8442

Please sign in to comment.