First POC
This commit is contained in:
commit
0cce7f9e2a
28 changed files with 1271 additions and 0 deletions
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
*.pyc
|
||||
*.egg-info
|
||||
youmap/settings/local.py
|
||||
youmap/settings/local/*
|
||||
docs/_build
|
23
README.rst
Normal file
23
README.rst
Normal file
|
@ -0,0 +1,23 @@
|
|||
YouMap project
|
||||
==============
|
||||
|
||||
Quickstart
|
||||
----------
|
||||
|
||||
To bootstrap the project::
|
||||
|
||||
virtualenv youmap
|
||||
source youmap/bin/activate
|
||||
cd path/to/youmap/repository
|
||||
pip install -r requirements.pip
|
||||
pip install -e .
|
||||
cp youmap/settings/local.py.example youmap/settings/local.py
|
||||
manage.py syncdb --migrate
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
Developer documentation is available in Sphinx format in the docs directory.
|
||||
|
||||
Initial installation instructions (including how to build the documentation as
|
||||
HTML) can be found in docs/install.rst.
|
88
docs/Makefile
Normal file
88
docs/Makefile
Normal file
|
@ -0,0 +1,88 @@
|
|||
# Makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
|
||||
# Internal variables.
|
||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||
PAPEROPT_letter = -D latex_paper_size=letter
|
||||
ALLSPHINXOPTS = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
|
||||
.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
|
||||
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
@echo " html to make standalone HTML files"
|
||||
@echo " dirhtml to make HTML files named index.html in directories"
|
||||
@echo " pickle to make pickle files"
|
||||
@echo " json to make JSON files"
|
||||
@echo " htmlhelp to make HTML files and a HTML help project"
|
||||
@echo " qthelp to make HTML files and a qthelp project"
|
||||
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||
@echo " changes to make an overview of all changed/added/deprecated items"
|
||||
@echo " linkcheck to check all external links for integrity"
|
||||
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
||||
|
||||
clean:
|
||||
-rm -rf _build/*
|
||||
|
||||
html:
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in _build/html."
|
||||
|
||||
dirhtml:
|
||||
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) _build/dirhtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in _build/dirhtml."
|
||||
|
||||
pickle:
|
||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle
|
||||
@echo
|
||||
@echo "Build finished; now you can process the pickle files."
|
||||
|
||||
json:
|
||||
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) _build/json
|
||||
@echo
|
||||
@echo "Build finished; now you can process the JSON files."
|
||||
|
||||
htmlhelp:
|
||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||
".hhp project file in _build/htmlhelp."
|
||||
|
||||
qthelp:
|
||||
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) _build/qthelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||
".qhcp project file in _build/qthelp, like this:"
|
||||
@echo "# qcollectiongenerator _build/qthelp/project.qhcp"
|
||||
@echo "To view the help file:"
|
||||
@echo "# assistant -collectionFile _build/qthelp/project.qhc"
|
||||
|
||||
latex:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex
|
||||
@echo
|
||||
@echo "Build finished; the LaTeX files are in _build/latex."
|
||||
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
|
||||
"run these through (pdf)latex."
|
||||
|
||||
changes:
|
||||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes
|
||||
@echo
|
||||
@echo "The overview file is in _build/changes."
|
||||
|
||||
linkcheck:
|
||||
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck
|
||||
@echo
|
||||
@echo "Link check complete; look for any errors in the above output " \
|
||||
"or in _build/linkcheck/output.txt."
|
||||
|
||||
doctest:
|
||||
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) _build/doctest
|
||||
@echo "Testing of doctests in the sources finished, look at the " \
|
||||
"results in _build/doctest/output.txt."
|
195
docs/conf.py
Normal file
195
docs/conf.py
Normal file
|
@ -0,0 +1,195 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# youmap documentation build configuration file, created by
|
||||
# sphinx-quickstart on Wed Aug 19 10:27:46 2009.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys, os
|
||||
import datetime
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.append(os.path.abspath('.'))
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = ['sphinx.ext.autodoc']
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'youmap'
|
||||
copyright = u'%d, myauthor' % datetime.date.today().year
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '1.0'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '1.0'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of documents that shouldn't be included in the build.
|
||||
#unused_docs = []
|
||||
|
||||
# List of directories, relative to source directory, that shouldn't be searched
|
||||
# for source files.
|
||||
exclude_trees = ['_build']
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. Major themes that come with
|
||||
# Sphinx are currently 'default' and 'sphinxdoc'.
|
||||
html_theme = 'default'
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_use_modindex = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
|
||||
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = ''
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'youmapdoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
||||
# The paper size ('letter' or 'a4').
|
||||
#latex_paper_size = 'letter'
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#latex_font_size = '10pt'
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'youmap.tex', u'youmap Documentation',
|
||||
u'myauthor', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#latex_preamble = ''
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_use_modindex = True
|
28
docs/deployment.rst
Normal file
28
docs/deployment.rst
Normal file
|
@ -0,0 +1,28 @@
|
|||
Deployment
|
||||
==========
|
||||
|
||||
Staging/Development
|
||||
-------------------
|
||||
|
||||
`Fabric <http://pypi.python.org/pypi/Fabric>`_ is used to allow developers to
|
||||
easily push changes to a previously setup development/staging environment.
|
||||
To get started, install Fabric by running the following command from within
|
||||
your virtual environment::
|
||||
|
||||
pip install fabric==1.4
|
||||
|
||||
So see a list of available commands, run the following command from within your
|
||||
project directory::
|
||||
|
||||
fab -l
|
||||
|
||||
Some common commands::
|
||||
|
||||
fab restart # Restart the web server.
|
||||
fab update # Just update the repository.
|
||||
fab push deploy # Push, then fully deploy.
|
||||
|
||||
From the within the project directory, you can just run ``fab [command]``.
|
||||
If you want to run fabric outside of the directory, use::
|
||||
|
||||
fab --fabfile /path/to/project/fabfile.py [command]
|
17
docs/environments.rst
Normal file
17
docs/environments.rst
Normal file
|
@ -0,0 +1,17 @@
|
|||
==================
|
||||
Environments
|
||||
==================
|
||||
|
||||
When deploying to multiple environments (development, staging, production, etc.), you'll likely want to deploy different configurations. Each environment/configuration should have its own file in ``youmap/settings`` and inherit from ``youmap.settings.base``. A ``dev`` environment is provided as an example.
|
||||
|
||||
By default, ``manage.py`` and ``wsgi.py`` will use ``youmap.settings.local`` if no settings module has been defined. To override this, use the standard Django constructs (setting the ``DJANGO_SETTINGS_MODULE`` environment variable or passing in ``--settings=youmap.settings.<env>``). Alternatively, you can symlink your environment's settings to ``youmap/settings/local.py``.
|
||||
|
||||
You may want to have different ``wsgi.py`` and ``urls.py`` files for different environments as well. If so, simply follow the directory structure laid out by ``youmap/settings``, for example::
|
||||
|
||||
wsgi/
|
||||
__init__.py
|
||||
base.py
|
||||
dev.py
|
||||
...
|
||||
|
||||
The settings files have examples of how to point Django to these specific environments.
|
19
docs/index.rst
Normal file
19
docs/index.rst
Normal file
|
@ -0,0 +1,19 @@
|
|||
Welcome to youmap's documentation!
|
||||
=====================================
|
||||
|
||||
Contents:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
install
|
||||
environments
|
||||
deployment
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
|
57
docs/install.rst
Normal file
57
docs/install.rst
Normal file
|
@ -0,0 +1,57 @@
|
|||
==================
|
||||
Installation
|
||||
==================
|
||||
|
||||
Pre-Requisites
|
||||
===============
|
||||
|
||||
* `setuptools <http://pypi.python.org/pypi/setuptools>`_
|
||||
* `virtualenv <http://pypi.python.org/pypi/virtualenv>`_
|
||||
|
||||
To install all of these system dependencies on a Debian-based system, run::
|
||||
|
||||
sudo apt-get install python-setuptools
|
||||
sudo easy_install virtualenv
|
||||
|
||||
|
||||
Creating the Virtual Environment
|
||||
================================
|
||||
|
||||
First, create a clean base environment using virtualenv::
|
||||
|
||||
virtualenv youmap
|
||||
cd youmap
|
||||
source bin/activate
|
||||
|
||||
|
||||
Installing the Project
|
||||
======================
|
||||
|
||||
Install the requirements and the project source::
|
||||
|
||||
cd path/to/your/youmap/repository
|
||||
pip install -r requirements.pip
|
||||
pip install -e .
|
||||
|
||||
|
||||
Configuring a Local Environment
|
||||
===============================
|
||||
|
||||
If you're just checking the project out locally, you can copy some example
|
||||
configuration files to get started quickly::
|
||||
|
||||
cp youmap/settings/local.py.example youmap/settings/local.py
|
||||
manage.py syncdb --migrate
|
||||
|
||||
|
||||
Building Documentation
|
||||
======================
|
||||
|
||||
Documentation is available in ``docs`` and can be built into a number of
|
||||
formats using `Sphinx <http://pypi.python.org/pypi/Sphinx>`_. To get started::
|
||||
|
||||
pip install Sphinx
|
||||
cd docs
|
||||
make html
|
||||
|
||||
This creates the documentation in HTML format at ``docs/_build/html``.
|
239
fabfile.py
vendored
Normal file
239
fabfile.py
vendored
Normal file
|
@ -0,0 +1,239 @@
|
|||
from fabric.api import task, env, run, local, roles, cd, execute, hide, puts,\
|
||||
sudo
|
||||
import posixpath
|
||||
import re
|
||||
|
||||
env.project_name = 'youmap'
|
||||
env.repository = 'git@github.com:lincolnloop/youmap.git'
|
||||
env.local_branch = 'master'
|
||||
env.remote_ref = 'origin/master'
|
||||
env.requirements_file = 'requirements.pip'
|
||||
env.restart_command = 'supervisorctl restart {project_name}'.format(**env)
|
||||
env.restart_sudo = True
|
||||
|
||||
|
||||
#==============================================================================
|
||||
# Tasks which set up deployment environments
|
||||
#==============================================================================
|
||||
|
||||
@task
|
||||
def live():
|
||||
"""
|
||||
Use the live deployment environment.
|
||||
"""
|
||||
server = 'youmap.com'
|
||||
env.roledefs = {
|
||||
'web': [server],
|
||||
'db': [server],
|
||||
}
|
||||
env.system_users = {server: 'www-data'}
|
||||
env.virtualenv_dir = '/srv/www/{project_name}'.format(**env)
|
||||
env.project_dir = '{virtualenv_dir}/src/{project_name}'.format(**env)
|
||||
env.project_conf = '{project_name}.settings.local'.format(**env)
|
||||
|
||||
|
||||
@task
|
||||
def dev():
|
||||
"""
|
||||
Use the development deployment environment.
|
||||
"""
|
||||
server = 'youmap.dev.lincolnloop.com'
|
||||
env.roledefs = {
|
||||
'web': [server],
|
||||
'db': [server],
|
||||
}
|
||||
env.system_users = {server: 'www-data'}
|
||||
env.virtualenv_dir = '/srv/www/{project_name}'.format(**env)
|
||||
env.project_dir = '{virtualenv_dir}/src/{project_name}'.format(**env)
|
||||
env.project_conf = '{project_name}.conf.local'.format(**env)
|
||||
|
||||
|
||||
# Set the default environment.
|
||||
dev()
|
||||
|
||||
|
||||
#==============================================================================
|
||||
# Actual tasks
|
||||
#==============================================================================
|
||||
|
||||
@task
|
||||
@roles('web', 'db')
|
||||
def bootstrap(action=''):
|
||||
"""
|
||||
Bootstrap the environment.
|
||||
"""
|
||||
with hide('running', 'stdout'):
|
||||
exists = run('if [ -d "{virtualenv_dir}" ]; then echo 1; fi'\
|
||||
.format(**env))
|
||||
if exists and not action == 'force':
|
||||
puts('Assuming {host} has already been bootstrapped since '
|
||||
'{virtualenv_dir} exists.'.format(**env))
|
||||
return
|
||||
sudo('virtualenv {virtualenv_dir}'.format(**env))
|
||||
if not exists:
|
||||
sudo('mkdir -p {0}'.format(posixpath.dirname(env.virtualenv_dir)))
|
||||
sudo('git clone {repository} {project_dir}'.format(**env))
|
||||
sudo('{virtualenv_dir}/bin/pip install -e {project_dir}'.format(**env))
|
||||
with cd(env.virtualenv_dir):
|
||||
sudo('chown -R {user} .'.format(**env))
|
||||
fix_permissions()
|
||||
requirements()
|
||||
puts('Bootstrapped {host} - database creation needs to be done manually.'\
|
||||
.format(**env))
|
||||
|
||||
|
||||
@task
|
||||
@roles('web', 'db')
|
||||
def push():
|
||||
"""
|
||||
Push branch to the repository.
|
||||
"""
|
||||
remote, dest_branch = env.remote_ref.split('/', 1)
|
||||
local('git push {remote} {local_branch}:{dest_branch}'.format(
|
||||
remote=remote, dest_branch=dest_branch, **env))
|
||||
|
||||
|
||||
@task
|
||||
def deploy(verbosity='normal'):
|
||||
"""
|
||||
Full server deploy.
|
||||
|
||||
Updates the repository (server-side), synchronizes the database, collects
|
||||
static files and then restarts the web service.
|
||||
"""
|
||||
if verbosity == 'noisy':
|
||||
hide_args = []
|
||||
else:
|
||||
hide_args = ['running', 'stdout']
|
||||
with hide(*hide_args):
|
||||
puts('Updating repository...')
|
||||
execute(update)
|
||||
puts('Collecting static files...')
|
||||
execute(collectstatic)
|
||||
puts('Synchronizing database...')
|
||||
execute(syncdb)
|
||||
puts('Restarting web server...')
|
||||
execute(restart)
|
||||
|
||||
|
||||
@task
|
||||
@roles('web', 'db')
|
||||
def update(action='check'):
|
||||
"""
|
||||
Update the repository (server-side).
|
||||
|
||||
By default, if the requirements file changed in the repository then the
|
||||
requirements will be updated. Use ``action='force'`` to force
|
||||
updating requirements. Anything else other than ``'check'`` will avoid
|
||||
updating requirements at all.
|
||||
"""
|
||||
with cd(env.project_dir):
|
||||
remote, dest_branch = env.remote_ref.split('/', 1)
|
||||
run('git fetch {remote}'.format(remote=remote,
|
||||
dest_branch=dest_branch, **env))
|
||||
with hide('running', 'stdout'):
|
||||
changed_files = run('git diff-index --cached --name-only '
|
||||
'{remote_ref}'.format(**env)).splitlines()
|
||||
if not changed_files and action != 'force':
|
||||
# No changes, we can exit now.
|
||||
return
|
||||
if action == 'check':
|
||||
reqs_changed = env.requirements_file in changed_files
|
||||
else:
|
||||
reqs_changed = False
|
||||
run('git merge {remote_ref}'.format(**env))
|
||||
run('find -name "*.pyc" -delete')
|
||||
run('git clean -df')
|
||||
fix_permissions()
|
||||
if action == 'force' or reqs_changed:
|
||||
# Not using execute() because we don't want to run multiple times for
|
||||
# each role (since this task gets run per role).
|
||||
requirements()
|
||||
|
||||
|
||||
@task
|
||||
@roles('web')
|
||||
def collectstatic():
|
||||
"""
|
||||
Collect static files from apps and other locations in a single location.
|
||||
"""
|
||||
dj('collectstatic --link --noinput')
|
||||
with cd('{virtualenv_dir}/var/static'.format(**env)):
|
||||
fix_permissions()
|
||||
|
||||
|
||||
@task
|
||||
@roles('db')
|
||||
def syncdb(sync=True, migrate=True):
|
||||
"""
|
||||
Synchronize the database.
|
||||
"""
|
||||
dj('syncdb --migrate --noinput')
|
||||
|
||||
|
||||
@task
|
||||
@roles('web')
|
||||
def restart():
|
||||
"""
|
||||
Restart the web service.
|
||||
"""
|
||||
if env.restart_sudo:
|
||||
cmd = sudo
|
||||
else:
|
||||
cmd = run
|
||||
cmd(env.restart_command)
|
||||
|
||||
|
||||
@task
|
||||
@roles('web', 'db')
|
||||
def requirements():
|
||||
"""
|
||||
Update the requirements.
|
||||
"""
|
||||
run('{virtualenv_dir}/bin/pip install -r {project_dir}/requirements.txt'\
|
||||
.format(**env))
|
||||
with cd('{virtualenv_dir}/src'.format(**env)):
|
||||
with hide('running', 'stdout', 'stderr'):
|
||||
dirs = []
|
||||
for path in run('ls -db1 -- */').splitlines():
|
||||
full_path = posixpath.normpath(posixpath.join(env.cwd, path))
|
||||
if full_path != env.project_dir:
|
||||
dirs.append(path)
|
||||
if dirs:
|
||||
fix_permissions(' '.join(dirs))
|
||||
with cd(env.virtualenv_dir):
|
||||
with hide('running', 'stdout'):
|
||||
match = re.search(r'\d+\.\d+', run('bin/python --version'))
|
||||
if match:
|
||||
with cd('lib/python{0}/site-packages'.format(match.group())):
|
||||
fix_permissions()
|
||||
|
||||
|
||||
#==============================================================================
|
||||
# Helper functions
|
||||
#==============================================================================
|
||||
|
||||
def dj(command):
|
||||
"""
|
||||
Run a Django manage.py command on the server.
|
||||
"""
|
||||
run('{virtualenv_dir}/bin/manage.py {dj_command} '
|
||||
'--settings {project_conf}'.format(dj_command=command, **env))
|
||||
|
||||
|
||||
def fix_permissions(path='.'):
|
||||
"""
|
||||
Fix the file permissions.
|
||||
"""
|
||||
if ' ' in path:
|
||||
full_path = '{path} (in {cwd})'.format(path=path, cwd=env.cwd)
|
||||
else:
|
||||
full_path = posixpath.normpath(posixpath.join(env.cwd, path))
|
||||
puts('Fixing {0} permissions'.format(full_path))
|
||||
with hide('running'):
|
||||
system_user = env.system_users.get(env.host)
|
||||
if system_user:
|
||||
run('chmod -R g=rX,o= -- {0}'.format(path))
|
||||
run('chgrp -R {0} -- {1}'.format(system_user, path))
|
||||
else:
|
||||
run('chmod -R go= -- {0}'.format(path))
|
11
manage.py
Normal file
11
manage.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE",
|
||||
"youmap.settings.local")
|
||||
|
||||
from django.core.management import execute_from_command_line
|
||||
|
||||
execute_from_command_line(sys.argv)
|
10
requirements.pip
Normal file
10
requirements.pip
Normal file
|
@ -0,0 +1,10 @@
|
|||
# This file collects all required third-party applications that are needed
|
||||
# to run this project. Later you can install all these apps in a row
|
||||
# using pip. Example::
|
||||
#
|
||||
# pip install -r requirements.pip
|
||||
|
||||
django==1.4.2
|
||||
#south==0.7.6
|
||||
git+git://github.com/petry/django-foundation.git
|
||||
git+git://github.com/yohanboniface/django-chickpea.git
|
14
setup.py
Normal file
14
setup.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env python
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name='youmap',
|
||||
version='1.0',
|
||||
description="",
|
||||
author="Lincoln Loop",
|
||||
author_email='info@lincolnloop.com',
|
||||
url='',
|
||||
packages=find_packages(),
|
||||
package_data={'youmap': ['static/*.*', 'templates/*.*']},
|
||||
scripts=['manage.py'],
|
||||
)
|
0
youmap/__init__.py
Normal file
0
youmap/__init__.py
Normal file
0
youmap/apps/__init__.py
Normal file
0
youmap/apps/__init__.py
Normal file
0
youmap/settings/__init__.py
Normal file
0
youmap/settings/__init__.py
Normal file
125
youmap/settings/base.py
Normal file
125
youmap/settings/base.py
Normal file
|
@ -0,0 +1,125 @@
|
|||
"""Base settings shared by all environments"""
|
||||
# Import global settings to make it easier to extend settings.
|
||||
from django.conf.global_settings import * # pylint: disable=W0614,W0401
|
||||
|
||||
#==============================================================================
|
||||
# Generic Django project settings
|
||||
#==============================================================================
|
||||
|
||||
DEBUG = True
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
SITE_ID = 1
|
||||
# Local time zone for this installation. Choices can be found here:
|
||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||
TIME_ZONE = 'UTC'
|
||||
USE_TZ = True
|
||||
USE_I18N = True
|
||||
USE_L10N = True
|
||||
LANGUAGE_CODE = 'en'
|
||||
LANGUAGES = (
|
||||
('en', 'English'),
|
||||
)
|
||||
|
||||
# Make this unique, and don't share it with anybody.
|
||||
SECRET_KEY = 'j6fly6aomgo6!3_$v#9kvhw-%wgs1@1l6x+4nr73tmn40=&_@&'
|
||||
|
||||
INSTALLED_APPS = (
|
||||
# 'youmap.apps.',
|
||||
'chickpea',
|
||||
'foundation',
|
||||
|
||||
#'south',
|
||||
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.admindocs',
|
||||
'django.contrib.gis',
|
||||
)
|
||||
|
||||
#==============================================================================
|
||||
# Calculation of directories relative to the project module location
|
||||
#==============================================================================
|
||||
|
||||
import os
|
||||
import sys
|
||||
import youmap as project_module
|
||||
|
||||
PROJECT_DIR = os.path.dirname(os.path.realpath(project_module.__file__))
|
||||
|
||||
PYTHON_BIN = os.path.dirname(sys.executable)
|
||||
ve_path = os.path.dirname(os.path.dirname(os.path.dirname(PROJECT_DIR)))
|
||||
# Assume that the presence of 'activate_this.py' in the python bin/
|
||||
# directory means that we're running in a virtual environment.
|
||||
if os.path.exists(os.path.join(PYTHON_BIN, 'activate_this.py')):
|
||||
# We're running with a virtualenv python executable.
|
||||
VAR_ROOT = os.path.join(os.path.dirname(PYTHON_BIN), 'var')
|
||||
elif ve_path and os.path.exists(os.path.join(ve_path, 'bin',
|
||||
'activate_this.py')):
|
||||
# We're running in [virtualenv_root]/src/[project_name].
|
||||
VAR_ROOT = os.path.join(ve_path, 'var')
|
||||
else:
|
||||
# Set the variable root to a path in the project which is
|
||||
# ignored by the repository.
|
||||
VAR_ROOT = os.path.join(PROJECT_DIR, 'var')
|
||||
|
||||
if not os.path.exists(VAR_ROOT):
|
||||
os.mkdir(VAR_ROOT)
|
||||
|
||||
#==============================================================================
|
||||
# Project URLS and media settings
|
||||
#==============================================================================
|
||||
|
||||
ROOT_URLCONF = 'youmap.urls'
|
||||
|
||||
LOGIN_URL = '/login/'
|
||||
LOGOUT_URL = '/logout/'
|
||||
LOGIN_REDIRECT_URL = '/'
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
MEDIA_URL = '/uploads/'
|
||||
|
||||
STATIC_ROOT = os.path.join(VAR_ROOT, 'static')
|
||||
MEDIA_ROOT = os.path.join(VAR_ROOT, 'uploads')
|
||||
|
||||
STATICFILES_DIRS = (
|
||||
os.path.join(PROJECT_DIR, 'static'),
|
||||
)
|
||||
|
||||
#==============================================================================
|
||||
# Templates
|
||||
#==============================================================================
|
||||
|
||||
TEMPLATE_DIRS = (
|
||||
os.path.join(PROJECT_DIR, 'templates'),
|
||||
)
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS += (
|
||||
)
|
||||
|
||||
#==============================================================================
|
||||
# Middleware
|
||||
#==============================================================================
|
||||
|
||||
MIDDLEWARE_CLASSES += (
|
||||
)
|
||||
|
||||
#==============================================================================
|
||||
# Auth / security
|
||||
#==============================================================================
|
||||
|
||||
AUTHENTICATION_BACKENDS += (
|
||||
)
|
||||
|
||||
#==============================================================================
|
||||
# Miscellaneous project settings
|
||||
#==============================================================================
|
||||
|
||||
#==============================================================================
|
||||
# Third party app settings
|
||||
#==============================================================================
|
20
youmap/settings/dev.py
Normal file
20
youmap/settings/dev.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
"""Settings for Development Server"""
|
||||
from youmap.settings.base import * # pylint: disable=W0614,W0401
|
||||
|
||||
DEBUG = True
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
VAR_ROOT = '/var/www/youmap'
|
||||
MEDIA_ROOT = os.path.join(VAR_ROOT, 'uploads')
|
||||
STATIC_ROOT = os.path.join(VAR_ROOT, 'static')
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'youmap',
|
||||
# 'USER': 'dbuser',
|
||||
# 'PASSWORD': 'dbpassword',
|
||||
}
|
||||
}
|
||||
|
||||
# WSGI_APPLICATION = 'youmap.wsgi.dev.application'
|
0
youmap/static/.gitignore
vendored
Normal file
0
youmap/static/.gitignore
vendored
Normal file
32
youmap/static/youmap/youmap.css
Normal file
32
youmap/static/youmap/youmap.css
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
Foundation use a position:relative; on body, which break the 100% rule
|
||||
on #map
|
||||
*/
|
||||
body.map_detail {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: inherit;
|
||||
}
|
||||
|
||||
/* HOME */
|
||||
.map_fragment {
|
||||
width: 100%;
|
||||
}
|
||||
.map_list .map_fragment {
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
/* Modals */
|
||||
.reveal-modal.update-tilelayers {
|
||||
width: 75%;
|
||||
max-height: 500px; /* TODO Make it dynamic */
|
||||
overflow: auto;
|
||||
margin-left: -35%;
|
||||
}
|
||||
|
||||
/* Global alert */
|
||||
.alert-box.global {
|
||||
z-index: 1001;
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
}
|
5
youmap/templates/404.html
Normal file
5
youmap/templates/404.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
Not Found
|
||||
{% endblock %}
|
14
youmap/templates/500.html
Normal file
14
youmap/templates/500.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{% block head_title %}{% endblock %}</title>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
Server Error
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
70
youmap/templates/base.html
Normal file
70
youmap/templates/base.html
Normal file
|
@ -0,0 +1,70 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{% block head_title %}YouMap{% endblock %}</title>
|
||||
<meta charset="utf-8">
|
||||
<!-- Included CSS Files (Compressed) -->
|
||||
<link rel="stylesheet" href="{{ STATIC_URL }}foundation/stylesheets/foundation.css">
|
||||
<link rel="stylesheet" href="{{ STATIC_URL }}youmap/youmap.css">
|
||||
|
||||
<script src="{{ STATIC_URL }}foundation/javascripts/modernizr.foundation.js"></script>
|
||||
|
||||
<!-- IE Fix for HTML5 Tags -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
{% block extra_head %}
|
||||
{% endblock extra_head %}
|
||||
|
||||
</head>
|
||||
<body class="{% block body_class %}{% endblock %}">
|
||||
|
||||
<div>
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
||||
<script src="{{ STATIC_URL }}foundation/javascripts/modernizr.foundation.js"></script>
|
||||
<script src="{{ STATIC_URL }}foundation/javascripts/jquery.js"></script>
|
||||
<script src="{{ STATIC_URL }}foundation/javascripts/jquery.foundation.mediaQueryToggle.js"></script>
|
||||
<script src="{{ STATIC_URL }}foundation/javascripts/jquery.foundation.reveal.js"></script>
|
||||
<script src="{{ STATIC_URL }}foundation/javascripts/jquery.foundation.orbit.js"></script>
|
||||
<script src="{{ STATIC_URL }}foundation/javascripts/jquery.foundation.navigation.js"></script>
|
||||
<script src="{{ STATIC_URL }}foundation/javascripts/jquery.foundation.buttons.js"></script>
|
||||
<script src="{{ STATIC_URL }}foundation/javascripts/jquery.foundation.tabs.js"></script>
|
||||
<script src="{{ STATIC_URL }}foundation/javascripts/jquery.foundation.forms.js"></script>
|
||||
<script src="{{ STATIC_URL }}foundation/javascripts/jquery.foundation.tooltips.js"></script>
|
||||
<script src="{{ STATIC_URL }}foundation/javascripts/jquery.foundation.accordion.js"></script>
|
||||
<script src="{{ STATIC_URL }}foundation/javascripts/jquery.placeholder.js"></script>
|
||||
<script src="{{ STATIC_URL }}foundation/javascripts/jquery.foundation.alerts.js"></script>
|
||||
{% block bottom_js %}
|
||||
<script type="text/javascript">
|
||||
$(document).foundationAlerts();
|
||||
L.Util.chickpea_modal = function (content, context) {
|
||||
var $div = $('#reveal-container');
|
||||
// reset class
|
||||
$div.attr("class", "");
|
||||
$div.addClass("reveal-modal");
|
||||
if (context && context.class) {
|
||||
$div.addClass(context.class);
|
||||
}
|
||||
return $div.empty().html(content).append('<a class="close-reveal-modal">×</a>').reveal();
|
||||
};
|
||||
L.Util.chickpea_alert = function (content, level, context) {
|
||||
console.log("alert", content);
|
||||
$div = $('<div>').addClass('alert-box success global').html(content);
|
||||
$div.append('<a href="#" class="close">×</a>');
|
||||
$("body").prepend($div);
|
||||
};
|
||||
$('a.reveal').click(function(e) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
$.get($this.attr('href'), function(data) {
|
||||
return L.Util.chickpea_modal(data.html);
|
||||
}, 'json');
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
<div id="reveal-container" class="reveal-modal"></div>
|
||||
</body>
|
||||
</html>
|
31
youmap/templates/chickpea/map_form.html
Normal file
31
youmap/templates/chickpea/map_form.html
Normal file
|
@ -0,0 +1,31 @@
|
|||
<h3>Create your map now!</h3>
|
||||
<form action="{{ action_url }}" method="post" id="map_edit">
|
||||
{{ form.non_field_errors }}
|
||||
{% csrf_token %}
|
||||
{{ form.name }}
|
||||
{% for error in form.name.errors %}
|
||||
<small class="error">{{ error|escape }}</small>
|
||||
{% endfor %}
|
||||
{{ form.description }}
|
||||
{{ form.description.errors }}
|
||||
{{ form.zoom }}
|
||||
{{ form.center }}
|
||||
<input type="submit" class="button" />
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
$("#map_edit").on("submit", function (e) {
|
||||
e.preventDefault();
|
||||
L.Util.Xhr.submit_form("map_edit", {
|
||||
'callback': function (data) {
|
||||
if (data.redirect) {
|
||||
window.location = data.redirect;
|
||||
}
|
||||
else {
|
||||
$("#map_edit").parent().empty().append(data.html);
|
||||
}
|
||||
},
|
||||
'dataType': 'json'
|
||||
});
|
||||
});
|
||||
</script>
|
41
youmap/templates/chickpea/map_update_tilelayers.html
Normal file
41
youmap/templates/chickpea/map_update_tilelayers.html
Normal file
|
@ -0,0 +1,41 @@
|
|||
{% load chickpea_tags %}
|
||||
<h3>Choose your tilelayers</h3>
|
||||
<form action="{% url map_update_tilelayers map.pk %}" method="post" id="map_edit">
|
||||
{% csrf_token %}
|
||||
<ul class="block-grid four-up mobile">
|
||||
{% for tilelayer in tilelayers %}
|
||||
<li>
|
||||
<label for="tilelayer_{{ forloop.counter }}">
|
||||
{% tilelayer_preview tilelayer %}<div class="panel">
|
||||
<input type="checkbox" id="tilelayer_{{ forloop.counter }}" name="tilelayer_{{ forloop.counter }}" value="{{ tilelayer.pk }}" {% if tilelayer in map.tilelayers.all %}checked{% endif %} />
|
||||
{{ tilelayer.name }}
|
||||
</div>
|
||||
</label>
|
||||
</li>
|
||||
{% endfor %}
|
||||
<div class="row twelve columns">
|
||||
<input type="submit" class="button" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
$("#map_edit").on("submit", function (e) {
|
||||
e.preventDefault();
|
||||
L.Util.Xhr.submit_form("map_edit", {
|
||||
'callback': function (data) {
|
||||
if (data.redirect) {
|
||||
window.location = data.redirect;
|
||||
}
|
||||
else if (data.info) {
|
||||
$div = $('<div>').addClass('alert-box success').html(data.info);
|
||||
$div.append('<a href="#" class="close">×</a>');
|
||||
$("#map").prepend($div);
|
||||
}
|
||||
else {
|
||||
$("#map_edit").parent().empty().append(data.html);
|
||||
}
|
||||
},
|
||||
'dataType': 'json'
|
||||
});
|
||||
});
|
||||
</script>
|
160
youmap/templates/youmap/home.html
Normal file
160
youmap/templates/youmap/home.html
Normal file
|
@ -0,0 +1,160 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% load chickpea_tags %}
|
||||
|
||||
{% block extra_head %}
|
||||
{% chickpea_css %}
|
||||
{% chickpea_js %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="twelve columns">
|
||||
|
||||
<!-- Navigation -->
|
||||
|
||||
<nav class="top-bar contain-to-grid">
|
||||
<ul>
|
||||
<li class="name"><h1><a href="#">YouMap <em>alpha</em></a></h1></li>
|
||||
<li class="toggle-topbar"><a href="#"></a></li>
|
||||
</ul>
|
||||
|
||||
<section>
|
||||
<ul class="left">
|
||||
<li><a href="#">My maps</a></li>
|
||||
<li><a href="#">Log in</a></li>
|
||||
</ul>
|
||||
|
||||
<ul class="right">
|
||||
<li class="search">
|
||||
<form>
|
||||
<input type="search">
|
||||
</form>
|
||||
</li>
|
||||
|
||||
<li class="has-button">
|
||||
<a class="small button" href="#">Search</a>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</nav>
|
||||
|
||||
<!-- End Navigation -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="twelve columns">
|
||||
<div class="row">
|
||||
|
||||
<!-- Content -->
|
||||
|
||||
<div class="eight columns">
|
||||
<div class="panel radius">
|
||||
|
||||
<div class="row">
|
||||
<div class="six mobile-two columns">
|
||||
<h4>YouMap <em>alpha</em></h4><hr/>
|
||||
<h5 class="subheader">YouMap let you create map with OpenStreetMap layers in a minute and embed them in your site.<br /> This is a demo instance, you can host your own, it's <strong>open source</strong>!
|
||||
</h5>
|
||||
</div>
|
||||
<div class="six mobile-two columns">
|
||||
<h5>What you can do?</h5>
|
||||
<ol>
|
||||
<li>Choose the layers of your map</li>
|
||||
<li>Add POIs: markers, lines, polygons...</li>
|
||||
<li>Manage POIs colours and icons</li>
|
||||
<li>Batch import geostructured data (GEOJson...)</li>
|
||||
<li>Choose your licence</li>
|
||||
<li>Embed and share your map</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="four columns hide-for-small">
|
||||
|
||||
<h4>Action!</h4><hr/>
|
||||
|
||||
<a href="{% url map_add %}" class="reveal">
|
||||
<div class="panel radius callout" align="center">
|
||||
<strong>Test me</strong>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<a href="https://bitbucket.org/yohanboniface/youmap_project">
|
||||
<div class="panel radius callout" align="center">
|
||||
<strong>Fork me</strong>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- End Content -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="twelve columns">
|
||||
<hr />
|
||||
<h2>Browse maps</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="twelve columns">
|
||||
<div class="row map_list">
|
||||
{% for map_inst in maps %}
|
||||
<div class="twelve mobile-six columns">
|
||||
{% map_fragment map_inst %}
|
||||
<div class="panel"><strong>{{ map_inst.name }}</strong> — {{ map_inst.description }} <a href="{{ map_inst.get_absolute_url }}">See this map!</a></div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Footer -->
|
||||
|
||||
<footer class="row">
|
||||
<div class="twelve columns"><hr />
|
||||
<div class="row">
|
||||
|
||||
<div class="six columns">
|
||||
<p>© Copyright no one at all. Go to town.</p>
|
||||
</div>
|
||||
|
||||
<div class="six columns">
|
||||
<ul class="link-list right">
|
||||
<li><a href="#TODO">About</a></li>
|
||||
<li><a href="https://bitbucket.org/yohanboniface/youmap_project">Fork me</a></li>
|
||||
<li><a href="#">Link 3</a></li>
|
||||
<li><a href="#">Link 4</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- End Footer -->
|
||||
<!-- Included JS Files -->
|
||||
{% endblock content %}
|
||||
|
||||
|
||||
{% block bottom_js %}
|
||||
{{ block.super }}
|
||||
<script type="text/javascript">
|
||||
$(window).load(function() {
|
||||
$('#featured').orbit({
|
||||
fluid: '2x1',
|
||||
timer: false
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock bottom_js %}
|
23
youmap/urls.py
Normal file
23
youmap/urls.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.conf.urls.defaults import patterns, url, include
|
||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
from . import views
|
||||
|
||||
admin.autodiscover()
|
||||
|
||||
urlpatterns = patterns('',
|
||||
# (r'', include('youmap.apps.')),
|
||||
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
(r'^admin/', include(admin.site.urls)),
|
||||
url(r'^$', views.home, name="home"),
|
||||
(r'', include('chickpea.urls')),
|
||||
)
|
||||
|
||||
if settings.DEBUG and settings.MEDIA_ROOT:
|
||||
urlpatterns += static(settings.MEDIA_URL,
|
||||
document_root=settings.MEDIA_ROOT)
|
||||
urlpatterns += staticfiles_urlpatterns()
|
15
youmap/views.py
Normal file
15
youmap/views.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from django.views.generic import TemplateView
|
||||
|
||||
from chickpea.models import Map
|
||||
|
||||
|
||||
class Home(TemplateView):
|
||||
template_name = "youmap/home.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
maps = Map.objects.all()[:20]
|
||||
return {
|
||||
"maps": maps
|
||||
}
|
||||
|
||||
home = Home.as_view()
|
29
youmap/wsgi.py
Normal file
29
youmap/wsgi.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
"""
|
||||
WSGI config for youmap project.
|
||||
|
||||
This module contains the WSGI application used by Django's development server
|
||||
and any production WSGI deployments. It should expose a module-level variable
|
||||
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
|
||||
this application via the ``WSGI_APPLICATION`` setting.
|
||||
|
||||
Usually you will have the standard Django WSGI application here, but it also
|
||||
might make sense to replace the whole Django WSGI application with a custom one
|
||||
that later delegates to the Django one. For example, you could introduce WSGI
|
||||
middleware here, or combine a Django application with an application of another
|
||||
framework.
|
||||
|
||||
"""
|
||||
import os
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE",
|
||||
"youmap.settings.local")
|
||||
|
||||
# This application object is used by any WSGI server configured to use this
|
||||
# file. This includes Django's development server, if the WSGI_APPLICATION
|
||||
# setting points here.
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
application = get_wsgi_application()
|
||||
|
||||
# Apply WSGI middleware here.
|
||||
# from helloworld.wsgi import HelloWorldApplication
|
||||
# application = HelloWorldApplication(application)
|
Loading…
Reference in a new issue