Changeset 360
- Timestamp:
- 07/09/09 19:01:46 (4 years ago)
- Location:
- enpraxis.staticsite/trunk/enpraxis/staticsite
- Files:
-
- 3 edited
-
browser/controlpanel.py (modified) (3 diffs)
-
profiles/default/propertiestool.xml (modified) (1 diff)
-
utilities/staticsiteutility.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
enpraxis.staticsite/trunk/enpraxis/staticsite/browser/controlpanel.py
r345 r360 62 62 value_type=TextLine(),) 63 63 64 64 non_html_views = List(title=_(u'Non HTML Views'), 65 description=_(u'Views that are included but not based on HTML.'), 66 required=True, 67 value_type=TextLine(),) 65 68 66 69 class StaticSiteControlPanelAdapter(SchemaAdapterBase): … … 135 138 self.ssprops.views_to_add = views 136 139 140 def get_non_html_views(self): 141 return self.ssprops.non_html_views 142 143 def set_non_html_views(self, views): 144 self.ssprops.non_html_views = views 145 137 146 deployment_path = property(get_deployment_path, set_deployment_path) 138 147 deployment_url = property(get_deployment_url, set_deployment_url) … … 145 154 sections_to_ignore = property(get_sections_to_ignore, set_sections_to_ignore) 146 155 views_to_add = property(get_views_to_add, set_views_to_add) 147 156 non_html_views = property(get_non_html_views, set_non_html_views) 148 157 149 158 class StaticSiteControlPanel(ControlPanelForm): -
enpraxis.staticsite/trunk/enpraxis/staticsite/profiles/default/propertiestool.xml
r345 r360 60 60 <element value="sitemap" /> 61 61 <element value="presentation_view" /> 62 <element value="rss" /> 62 63 </property> 64 <property name="non_html_views" type="lines"> 65 <element value="rss" /> 66 </property> 63 67 </object> 64 68 </object> -
enpraxis.staticsite/trunk/enpraxis/staticsite/utilities/staticsiteutility.py
r358 r360 224 224 upath = urlparse(link['href']) 225 225 p = upath[2].split('/') 226 obj = p[:-1] 227 view = p[-1] 226 228 # If we are going to add the action, process it 227 if p[-1]in ssprops.getProperty('views_to_add'):229 if view in ssprops.getProperty('views_to_add'): 228 230 mpath = self._getObjPath(url, portal.portal_url(), dpath) 229 231 mpath = os.path.split(mpath) … … 231 233 asoup = BeautifulSoup(raw) 232 234 body = self.runDocumentFilters(portal, current, asoup, ssprops) 233 q = p[:-1] 234 results = portal.portal_catalog.searchResults(query={'path':'/'.join(q[:-1]),}, id=q[-1]) 235 results = portal.portal_catalog.searchResults( 236 query={'path':'/'.join(obj[:-1]),}, 237 id=obj[-1]) 235 238 if results: 236 239 if results[0].is_folderish: 237 mpath = '%s/index-%s .html' %(mpath[0], mpath[1])240 mpath = '%s/index-%s' %(mpath[0], mpath[1]) 238 241 else: 239 mpath = '%s-%s.html' %(mpath[0], mpath[1]) 242 mpath = '%s-%s' %(mpath[0], mpath[1]) 243 if view not in ssprops.getProperty('non_html_views'): 244 mpath += '.html' 240 245 self._writeFile(mpath, body) 241 246 242 def runViewFilters(self, id, portal, current, soup, ssprops):243 self.filterIgnoredSections(soup, ssprops)244 self.filterIgnoredActions(soup, ssprops)245 self.filterCSSLinks(soup, current)246 links = self.getDocumentLinks(soup)247 for x in links:248 orig = x['href']249 x['href'] = self.filterDocumentLink(x['href'],250 current,251 portal,252 ssprops.getProperty('views_to_add'))253 print ' (view-%s) %s => %s' %(id, orig, x['href'])254 return soup.prettify()255 256 def filterViewLink(self, link, current, views):257 lnk = link258 lnk = self._convertLinkToAbsolute(lnk, current)259 lnk = self._convertViewLink(lnk, views)260 lnk = self._convertLinkToRelative(lnk, current)261 return lnk262 263 def _convertViewLink(self, link, views):264 result = link265 url = urlparse(link)266 path = url[2].split('/')267 if path[-1] in views:268 if len(path) > 1:269 path[-2] += '-%s.html' %path[-1]270 path = path[:-1]271 result = urlunparse((url[0], url[1], '/'.join(path), url[3], url[4], url[5]))272 return result273 274 247 def runDocumentFilters(self, portal, current, soup, ssprops): 275 248 self.filterBaseTag(soup, current) … … 289 262 current, 290 263 portal, 291 ssprops.getProperty('views_to_add')) 264 ssprops.getProperty('views_to_add'), 265 ssprops.getProperty('non_html_views')) 292 266 print ' %s => %s' %(orig, x['href']) 293 267 … … 393 367 link['href'] = link['href'].replace(url, nurl) 394 368 369 def filterImageFullscreenBackLink(self, soup, current): 370 if 'image_view_fullscreen' in current: 371 back = soup.find('a') 372 if back: 373 lt = back.find('span') 374 if lt: 375 lt.contents[0].replaceWith('Back to Image') 376 if back.has_key('href'): 377 back['href'] = current.replace('image_view_fullscreen.html', 'view.html') 395 378 def getDocumentLinks(self, soup): 396 379 tags = soup.findAll('a') + soup.findAll('link') … … 403 386 return links 404 387 405 def filterImageFullscreenBackLink(self, soup, current): 406 if 'image_view_fullscreen' in current: 407 back = soup.find('a') 408 if back: 409 lt = back.find('span') 410 if lt: 411 lt.contents[0].replaceWith('Back to Image') 412 if back.has_key('href'): 413 back['href'] = current.replace('image_view_fullscreen.html', 'view.html') 414 415 416 def filterDocumentLink(self, link, current, portal, views): 388 def filterDocumentLink(self, link, current, portal, views, nviews): 417 389 lnk = link 418 390 url = urlparse(lnk) 419 391 if url[2] and 'javascript' != url[0]: 420 392 lnk = self._convertLinkToAbsolute(lnk, current) 421 lnk = self._convertObjectLink(lnk, portal, views )393 lnk = self._convertObjectLink(lnk, portal, views, nviews) 422 394 lnk = self._convertLinkToRelative(lnk, current) 423 395 return lnk … … 441 413 return result 442 414 443 def _convertObjectLink(self, link, portal, views ):415 def _convertObjectLink(self, link, portal, views, nviews): 444 416 # This only works for absolute links 445 417 result = link … … 457 429 if results[0].is_folderish: 458 430 if view: 459 path = '/'.join(h) + '/index' + '-%s .html' %view431 path = '/'.join(h) + '/index' + '-%s' %view 460 432 else: 461 433 path = '/'.join(h) + '/index.html' 462 434 else: 463 435 if view: 464 path = '/'.join(h) + '-%s .html' %view436 path = '/'.join(h) + '-%s' %view 465 437 elif h: 466 438 path = '/'.join(h) 467 439 if 'Page' == results[0].Type and '.htm' not in path: 468 440 path += '.html' 441 if view and view not in nviews: 442 path += '.html' 469 443 result = urlunparse((hr[0], hr[1], path, hr[3], hr[4], hr[5])) 470 444 elif link == portal.portal_url():
Note: See TracChangeset
for help on using the changeset viewer.
