Skip to content
Microweb is a Django web client for the Microcosm API.
JavaScript Python HTML Other
Latest commit 330b389 Apr 20, 2016 @buro9 buro9 Fix date display for events
Failed to load latest commit information.
comments require_safe to enable HEAD Jun 20, 2015
conversations require_safe to enable HEAD Jun 20, 2015
core Fix date display for events Apr 20, 2016
events require_safe to enable HEAD Jun 20, 2015
huddles require_safe to enable HEAD Jun 20, 2015
ignored require_safe to enable HEAD Jun 20, 2015
microcosms Fixed path of uploaded forum icons Jan 3, 2016
microweb Fixed events so that they always save and are displayed in UTC regard… Dec 20, 2015
moderation Fixed moderation issues where one of the forms used a GET! Mar 24, 2016
profiles Added ability for site admins to grant/revoke membership status Nov 1, 2015
redirect require_safe to enable HEAD Jun 20, 2015
search require_safe to enable HEAD Jun 20, 2015
today require_safe to enable HEAD Jun 20, 2015
trending require_safe to enable HEAD Jun 20, 2015
updates require_safe to enable HEAD Jun 20, 2015
utils Add ability to generate pages of comments to test utils Jan 24, 2014
.gitignore Resolved merge conflicts May 9, 2014
.travis.yml Turn off pip -q, --use-mirrors made no difference to build Feb 4, 2014
LICENSE 2014: The Year of the Microcosms Jan 9, 2014
OPENSOURCE.md Added open source credits Feb 28, 2014
README.md Rewrite README and bring up-to-date Aug 26, 2014
dependencies.sh updated to work on osx as well as linux Nov 17, 2014
fabfile.py Added a dev2 source for mocking custom servers attached to the infras… Dec 31, 2014
manage.py Add monkey patching of gevent to manage.py Mar 20, 2014
newrelic.ini.template Capture query parameters in new relic May 14, 2014
requirements.txt Fixed events so that they always save and are displayed in UTC regard… Dec 20, 2015
upstart.sh New VMs have 2 cores Sep 26, 2014

README.md

Microweb

Microco.sm is a new forum SaaS product, founded by David Kitchen and Matt Cottingham.

Communities are already using Microco.sm as their forum software of choice, such as the Espruino Forum and LFGSS.

Microweb is the official web client for Microco.sm, written in Django. If you're not familiar with the Microcosm API, you should start by reading the API documentation.

If you find any problems, just raise an issue on github and we'll respond ASAP.

Build Status

Project setup

To run the django project, you'll first need to create a python virtualenv by running the following:

virtualenv -p python2.7 envname
source envname/bin/activate
pip install -r requirements.txt

This will install all dependencies listed in requirements.txt. All commands should be executed with the virtual environment activated.

Project structure

As is good practice with Django projects, separate apps handle different areas of functionality. For instance, the conversations app contains the urls and views associated with conversations.

The layout is as follows:

├── microweb
│   ├── comments
│   ├── conversations
│   ├── core
│   ├── events
│   ├── huddles
│   ├── microcosms
│   ├── profiles
│   ├── search
│   ├── updates

The core package contains a client for the Microcosm API. If you're familiar with Django, the rest of the packages and modules will look familiar.

Tests

Unit tests can be run with:

python manage.py test

There is also an integration test suite using selenium that runs as a standalone process.

User authentication

Since authentication is handled by the API, custom middleware is used to provide the authentication context in views. We do this by checking the value of the access_token cookie.

In core/middleware/context.py:

def process_request(self, request):
    """
    Checks for access_token cookie and appends it to the request object if present.

    All request objects have a view_requests attribute which is a list of requests
    that will be executed by grequests to fetch data for the view.
    """

    request.access_token = None
    request.whoami_url = ''
    request.view_requests = []

    if request.COOKIES.has_key('access_token'):
        request.access_token = request.COOKIES['access_token']
        request.whoami_url, params, headers = WhoAmI.build_request(request.get_host(), request.access_token)
        request.view_requests.append(grequests.get(request.whoami_url, params=params, headers=headers))

    request.site_url, params, headers = Site.build_request(request.get_host())
    request.view_requests.append(grequests.get(request.site_url, params=params, headers=headers))

As you can see, request has view_requests attribute which is a list of requests to be made to the API to render the view. The requests are executed concurrently using grequests in the views themselves (there's more work to be done here, like having a reusable connection pool, but it works well enough for now).

So on each request we make a couple of calls to the API to check if the user has a valid access_token cookie, and retrieve some basic site data (title, description).

Running a development instance

If you've followed the instructions above on setting up a virtualenv, the next thing you'll need to do is fill in local_settings.py with your API key (email us if you don't have one). Use the template here as a guide.

If you run with DEBUG = True (for development only!), static files should work correctly. In production, we use nginx to serve these.

Deploying

We use fabric as our deployment tool. To use this with your own instance, you'll need to modify fabfile.py to contain the hosts you wish to deploy to.

Something went wrong with that request. Please try again.