Changeset 1836
- Timestamp:
- 11/03/08 15:54:57 (2 months ago)
- Location:
- siteapp/branches/clean-embed
- Files:
-
- 1 added
- 2 modified
-
data/embed.cfg (added)
-
opengeo/almanac/configutil.py (modified) (1 diff)
-
opengeo/almanac/content.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
siteapp/branches/clean-embed/opengeo/almanac/configutil.py
r1789 r1836 187 187 direct=True) 188 188 189 class EmbedRegister(ConfigLoadingUtil): 190 default = '/data/embed.cfg' 191 192 embedreg = EmbedRegister.from_spec() 193 grok.global_utility(embedreg, 194 provides=IConfigValues, 195 name="almanac.embed", 196 direct=True) 197 189 198 190 199 def test_suite(): -
siteapp/branches/clean-embed/opengeo/almanac/content.py
r1827 r1836 2 2 Our basic content and pedestrian add and edit views 3 3 """ 4 from lxml.html.clean import Cleaner 4 5 from opengeo.almanac import app 5 6 from opengeo.almanac import kml … … 169 170 elif type == 'video': 170 171 story.type = 'video' 171 story.body = extra_data['video'] 172 markup = extra_data['video'] 173 story.body = clean_embed_markup(markup) 172 174 else: 173 175 # assume text if it's not an image or video … … 191 193 192 194 return story 195 196 197 def clean_embed_markup(markup): 198 cfg = getUtility(IConfigValues, name='almanac.embed') 199 cfg = cfg['embed'] 200 allow_tags = cfg.allow_tags.split(',') 201 host_whitelist = cfg.host_whitelist.split(',') 202 203 # prefix www subdomain to all hosts as a convenience 204 host_whitelist = set([x.strip() for x in host_whitelist]) 205 for host in list(host_whitelist): 206 if not host.startswith('www.'): 207 host_whitelist.add('www.' + host) 208 209 cleaner = Cleaner(allow_tags=allow_tags, 210 remove_unknown_tags=False, 211 whitelist_tags=allow_tags, 212 host_whitelist=host_whitelist) 213 import pdb; pdb.set_trace() 214 return cleaner.clean_html(markup) 193 215 194 216 class BaseModel(grok.Model): … … 823 845 self.context.photoid = photoid 824 846 elif self.context.type == 'video' and 'video' in self.request.form: 825 self.context.body = self.request.form['video']847 self.context.body = clean_embed_markup(self.request.form['video']) 826 848 elif self.context.type == 'text' and 'words' in self.request.form: 827 849 self.context.body = self.request.form['words']
