Skip to content

Instantly share code, notes, and snippets.

View groovecoder's full-sized avatar

luke crouch groovecoder

View GitHub Profile
from django.views.generic.simple import direct_to_template
direct_templates = ['about', 'news']
for template in direct_templates:
urlpatterns = patterns('', (r'^%s/?$' % template), direct_to_template,
{'template': '%s.html' % template})
}
exec { 'npm-install':
cwd => "/home/vagrant/src/kumascript",
user => 'vagrant',
command => "/usr/bin/npm install fibers",
creates => "/home/vagrant/src/kumascript/node_modules/fibers",
require => [
Package["nodejs"], Package["nodejs-dev"], Package["npm"],
File["/usr/include/node"], File["/root/.npm"]
try:
doc._move_tree(new_slug, user=user)
except Exception as e:
message = """
Page move failed.
Move was requested for document with slug %(slug)s in locale %(locale)s,
but could not be completed. The following error was raised:
%(info)
<p><img alt="me" src="https://mdn-local.mozillademos.org/files/5840/luke_headshot_small.png" style="width: 128px; height: 123px;" /></p>
<h2 id="Test_stuff">Test stuff</h2>
<p><span class="seoSummary">Surely this is the only doc that mentions CodeforAmerica</span>.</p>
<h3 id="Embed_stuff">Embed stuff</h3>
<p>{{Stringify({ "gar": ["asdf","dsfg", "jkl"], "articles": ["\/en-US\/docs\/XUL"] }) }}</p>
<p>Change across sections</p>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">
def _inherited(parent_attr, direct_attr):
"""Return a descriptor delegating to an attr of the original document.
If `self` is a translation, the descriptor delegates to the attribute
`parent_attr` from the original document. Otherwise, it delegates to the
attribute `direct_attr` from `self`.
Use this only on a reference to another object, like a ManyToMany or a
ForeignKey. Using it on a normal field won't work well, as it'll preclude
the use of that field in QuerySet field lookups. Also, ModelForms that are
import session_csrf
session_csrf.monkeypatch()
from django.conf.urls.defaults import include, patterns, url
from django.conf import settings
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.shortcuts import redirect, render
{% if waffle.flag('ab_page_actions') %}
{% block ab_test_script %}
<script src="//cdn.optimizely.com/js/237572123.js"></script>
{% endblock %}
{% endif %}
<h2 name="Widget">Widget</h2>
<h3>HTML Content</h3>
<pre class="brush: html">
Sample HTML Content</pre>
<h3>CSS Content</h3>
<pre class="brush: css">
Sample CSS Content</pre>
<h3>JavaScript Content</h3>
<pre class="brush: js">
Sample JavaScript Content</pre>
def get_excerpt(self):
stripped_matches = []
for match in self._highlight['content']:
stripped_matches.append(bleach.clean(match,
tags=['em',],
strip=True))
return u'...'.join(stripped_matches)
results = DocumentType.search()
if search_query:
results = (results.query(or_={'title': search_query,
'content': search_query})
.highlight('content'))
result_count = results.count()
results = results[start:end]
for doc in results:
for match in doc._highlight['content']:
match = bleach.clean(match, tags=['em',], strip=True)