Login

Snippets by jokull

Snippet List

Facebook event selector field

Ripped this out of a project I'm working on. The field renders as two <select> elements representing the two-level hierarchy organized events Facebook uses. Returns the id's Facebook wants.

  • forms
  • field
  • widget
  • facebook
  • fbml
  • fbjs
Read More

Different approach to local settings.py

I like to keep all local settings files in my versioning repository. The way I differentiate between them is by querying the hostname of the local machine. I've got a host_settings folder with local settings files. Notice that the local settings file names go by a convention where '.' is replaced with underscores. Example: host_settings/local_machine_tld.py

  • settings
  • development
  • deployment
Read More

CSS Preprocessor

Here is a Django view that turns code like this: @variables { $varcolor: #333; } body { color: $varcolor; padding: 20px; } .space { padding: 10px; } .small { font-size: 10px; } #banana(.space, .small) { margin-bottom: 10px; } And turns it into something like this: body { color: #333; padding: 20px; } #banana { padding: 10px; font-size: 10px; margin-bottom: 10px; } .small { font-size: 10px; } .space { padding: 10px; } Notice the variables declaration at the top. The other feature is *extending* - here #banana extends .space and .small. The url.py entry might look something like this: (r'^css/(?P<css>(\w|-)+)\.css$','csspp.csspp'), Here referencing csspp.py in your path (root directory of your site probably). The code also looks for a CSS_DIR setting in your settings file. You will probably want to point straight to your media/css/ directory. **Known problems** * There is now way of extending selectors that are already extending something else. In the example code there is now way to extend #banana since it is already extending .small and .space.

  • css
  • preprocessor
  • csspp
Read More

jokull has posted 4 snippets.