Skip to content

Commit

Permalink
Merge branch 'master' into myfreeweb/master
Browse files Browse the repository at this point in the history
  • Loading branch information
navilan committed Feb 6, 2011
2 parents 10130ad + 779b3b3 commit f5b76e6
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
28 changes: 28 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ These conventions will make it easier to configure hyde plugins.

Most of the boilerplate configuration comes as a part of the initialized website. The only setting you _have to_ override is the SITE_NAME setting.


### Media Processors

Media processors are defined in the following format:
Expand Down Expand Up @@ -398,6 +399,30 @@ To enable Typogrify, use ``{% filter typogrify %}`` in your code. Typogrify is "
[typogrify_site]:http://code.google.com/p/typogrify/
[smartypants]:http://web.chad.org/projects/smartypants.py/


## Preprocessors

Main information about preprocessors can be found in
[hyde wiki]:https://github.com/lakshmivyas/hyde/wiki/Site-Preprocessors

### Properties inclusion

Is preprocessor that includes new properties into nodes.
Simple configuration:
SITE_PRE_PROCESSORS = {
'/': {
'hydeengine.site_pre_processors.TranslationManager': {
'include' : {
'node_field': {'field':'page_field','fallback':'node_field2'}
}
}
}
}

Processors find listing page for node and then include page.field into node.node_field, and if there is no title it falls back to node.node_field2 field.
One can use it for translation, for example use field: page_field on native language and the use node field in template (to overcome node.name) or even add additiona menu_title to give title name to module.
N.B. you should explisitly create listing page otherwise preprocessor will not add any attribute to node.

## Base Templates

There are two layouts currently available: default and simple.
Expand Down Expand Up @@ -452,3 +477,6 @@ The following websites are built using hyde and are open sourced.
- [Paul Bonser](https://github.com/pib)
- [Yoann Pigné](https://github.com/pigne)
- [Hubert HANGHOFER](https://github.com/brewbert)
- [sirex](https://github.com/sirex)
- [Alexander Vershilov](https://github.com/qnikst)

4 changes: 3 additions & 1 deletion hydeengine/media_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def process(resource):
import clevercss
data = resource.source_file.read_all()
out = clevercss.convert(data)
resource.source_file.write(out)
out_file = File(resource.source_file.path_without_extension + ".css")
out_file.write(out)
resource.source_file.delete()

class HSS:
@staticmethod
Expand Down
22 changes: 22 additions & 0 deletions hydeengine/site_pre_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,25 @@ def __init__(self, keys, image):
for key, attr in mapping.items():
if key in keys:
setattr(resource.meta, attr, getattr(resource.meta, key))

class InclusionManager:
"""Inclusion Manager
Include listing page properties into corresponding node
"""
@staticmethod
def process(folder, params):
context = settings.CONTEXT
site = context['site']
node = params['node']

inclusions = params['include']

for inc_key, info in inclusions.iteritems():
for p in node.walk_pages():
if p.listing:
value = getattr(p, info['field'])
if value is None:
value = getattr(p.node, info['fallback'])
setattr(p.node,inc_key, value)

0 comments on commit f5b76e6

Please sign in to comment.