Skip to content

Instantly share code, notes, and snippets.

View philipn's full-sized avatar

Philip Neustrom philipn

View GitHub Profile
@philipn
philipn / gist:2907544
Created June 10, 2012 22:29
Cache cloudmade titles in localwiki
You'll want to replace 'localwiki.org' with your hostname here.
----------------------
Add to localsettings.py:
OLWIDGET_CUSTOM_LAYER_TYPES = {
'cachedcloudmade': """OpenLayers.Layer.CachedCloudMade('CachedCloudMade',
['//map-a.localwiki.org/tile/ca694687020d468283a545db191bcb81/35165/256/',
'//map-b.localwiki.org/tile/ca694687020d468283a545db191bcb81/35165/256/',
'//map-c.localwiki.org/tile/ca694687020d468283a545db191bcb81/35165/256/'])""",
}
{% load static from staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
class SlugifyMixin(object):
def obj_get(self, request=None, **kwargs):
slug = getattr(self._meta, 'slug_lookup_field', 'slug')
kwargs[slug] = slugify(kwargs[slug])
return super(SlugifyMixin, self).obj_get(request=request, **kwargs)
def override_urls(self):
slug = getattr(self._meta, 'slug_lookup_field', 'slug')
return [
url(r"^(?P<resource_name>%s)/(?P<%s>.+?)/*$" %
@philipn
philipn / request.py diff for SOPA PIPA
Created January 18, 2012 08:56
request.py diff for SOPA and PIPA
wikispot@leo:~/Sycamore$ diff request.py.old request.py
34a35,172
> MAX_POST_PER_MINUTE = 40
>
> DO_SOPA = True
> SOPA_HTML = """<html lang="en">
> <head>
> <title>Davis Wiki - Day of Protest</title>
>
> <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
@philipn
philipn / DavisWiki blackout page
Created January 18, 2012 04:41
daviswiki blackout HTML
<html lang="en">
<head>
<title>Day of Protest</title>
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<style type="text/css">
Run:
localwiki-manage shell
then enter this, afer editing the `ago` value:
import datetime
now = datetime.datetime.now()
###############
from django.middleware.cache import UpdateCacheMiddleware
from django.utils.cache import learn_cache_key, get_max_age
class UpdateCacheMiddlewareNoHeaders(UpdateCacheMiddleware):
"""
Just like UpdateCacheMiddleware but we don't set cache headers in the
HTTP response.
"""
@philipn
philipn / create_template_postgis-debian.sh
Created November 30, 2011 06:27
create_template_postgis-debian.sh WORKS ON 11.10
#!/bin/bash
# For Ubuntu 8.x and 9.x releases.
if [ -d "/usr/share/postgresql-8.3-postgis" ]
then
POSTGIS_SQL_PATH=/usr/share/postgresql-8.3-postgis
POSTGIS_SQL=lwpostgis.sql
fi
# For Ubuntu 10.04
== Updating to 0.2 ==
1. Move your current localsettings.py out of the sapling directory and rename it:
$ mv sapling/localsettings.py sapling/../localsettings.py.bak
2. Activate your virtualenv:
$ source env/bin/activate
@philipn
philipn / basepath for ckeditor
Created September 30, 2011 07:58
basepath for ckeditor
diff --git a/sapling/ckeditor/templates/ckeditor/ckeditor_script.html b/sapling/ckeditor/templates/ckeditor/ckeditor_script.html
index 7e3f404..6f536be 100644
--- a/sapling/ckeditor/templates/ckeditor/ckeditor_script.html
+++ b/sapling/ckeditor/templates/ckeditor/ckeditor_script.html
@@ -1,5 +1,6 @@
<script type="text/javascript">
<!--
+CKEDITOR.basePath = '{{ STATIC_URL }}js/ckeditor/';
CKEDITOR.replace('id_{{ name }}'{% if config %}, {{ config|safe }}{% endif %});
-->