author: Sylvain Viollon
date: Wed Jul 24 11:57:18 2013 +0200
revision: 31:121c1bb72810 in silva.fanstatic
branch:
details: https://hg.infrae.com/silva.fanstatic?cmd=changeset;node=121c1bb72810
modified: src/silva/fanstatic/injector.py
added:
removed:
log: Update to match yesterday changes in fanstatic.
diffstat:
src/silva/fanstatic/injector.py | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diffs (49 lines):
diff -r 4107dc4e74a9 -r 121c1bb72810 src/silva/fanstatic/injector.py
--- a/src/silva/fanstatic/injector.py Tue Jul 23 18:02:28 2013 +0200
+++ b/src/silva/fanstatic/injector.py Wed Jul 24 11:57:18 2013 +0200
@@ -1,11 +1,15 @@
-from fanstatic import compat, Inclusion
+from fanstatic import compat
+from fanstatic.inclusion import Inclusion
+from fanstatic.injector import InjectorPlugin
import re
+
class Test(object):
pass
+
class URLTest(Test):
name = 'the url ends with (path)'
expr = re.compile(r'the url ends with (?P<path>.*)')
@@ -125,6 +129,7 @@
def test(self, resource):
return resource.ext == '.css'
+
class ICOSelector(ResourceSelector):
selector = 'ico'
@@ -326,10 +331,11 @@
return default, rules
-class RuleBasedInjector(object):
+class RuleBasedInjector(InjectorPlugin):
name = 'rules'
def __init__(self, options):
+ super(RuleBasedInjector, self).__init__(options)
self.default, self.rules = parse_rules(options.pop('rules'))
def __call__(self, html, needed, request, response=None):
@@ -347,5 +353,6 @@
if self.default is not None:
includes.setdefault(self.default.inject, []).append(resource)
for injector, resources in includes.items():
- html = injector(html, Inclusion(needed, resources).render())
+ inclusion = self.make_inclusion(needed, resources)
+ html = injector(html, inclusion.render())
return html
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.