Changeset 529 for enpraxis.staticsite

Show
Ignore:
Timestamp:
08/06/09 16:05:15 (3 years ago)
Author:
david
Message:

adding logic to discover presentation view as it is no longer a document_action

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • enpraxis.staticsite/trunk/enpraxis/staticsite/utilities/staticsiteutility.py

    r507 r529  
    150150        path = self._getObjPath(url, portal.portal_url(), dpath) 
    151151        if folderish: 
    152             print '@@@ '+  url + '/index.html' 
     152            # print '@@@ '+  url + '/index.html' 
    153153            self.processDocument(url, portal, dpath, ssprops, True) 
    154154        elif ctype in ['Page']: 
    155155            # Fix this so that it deals with the case where you have both a file and a file.html in the 
    156156            # same folder 
    157             print '*** '+  url 
     157            # print '*** '+  url 
    158158            self.processDocument(url, portal, dpath, ssprops) 
    159159        else: 
     
    164164            aurl = urlparse(url) 
    165165            aurl = urlunparse((aurl[0], aurl[1], aurl[2] + '-view.html', aurl[3], aurl[4], aurl[5])) 
    166             print 'vvv '+  aurl 
     166            # print 'vvv '+  aurl 
    167167            self.processDocument(url + '/view', portal, dpath, ssprops, alturl=aurl) 
    168168            # If it is an image process the fullscreen view 
     
    170170                aurl = urlparse(url) 
    171171                aurl = urlunparse((aurl[0], aurl[1], aurl[2] + '-image_view_fullscreen.html', aurl[3], aurl[4], aurl[5])) 
    172                 print 'iii '+  aurl 
     172                # print 'iii '+  aurl 
    173173                self.processDocument(url + '/image_view_fullscreen', portal, dpath, ssprops, alturl=aurl) 
    174174 
     
    203203            return data 
    204204        except HTTPError, e:            
    205             print '!!! Error : %s %s for url: %s' % (e.code, e.msg, e.filename) 
     205            # print '!!! Error : %s %s for url: %s' % (e.code, e.msg, e.filename) 
    206206            return '' 
    207207             
     
    224224        soup = BeautifulSoup(raw) 
    225225        self.deployDocumentActions(portal, aurl, dpath, soup, ssprops) 
     226        self.deployPresentationView(portal, aurl, dpath, soup, ssprops)                 
    226227        self.deployNonActionNonHTMLViews(portal, aurl, dpath, soup, ssprops) 
    227228        if isFolderish: 
     
    236237            mpath += '.html' 
    237238        self._writeFile(mpath, body) 
     239 
     240    def deployPresentationView(self, portal, current, dpath, soup, ssprops): 
     241        #Look for presentation view 
     242        raw_pres = soup.find('p', id='link-presentation') 
     243        if raw_pres: 
     244            url = raw_pres.a['href'] 
     245            upath = urlparse(url) 
     246            p = upath[2].split('/') 
     247            obj = p[:-1] 
     248            view = p[-1] 
     249            if view in ssprops.getProperty('views_to_add'): 
     250                mpath = self._getObjPath(url, portal.portal_url(), dpath) 
     251                mpath = os.path.split(mpath) 
     252                raw = self._httpget(url) 
     253                asoup = BeautifulSoup(raw) 
     254                body = self.runDocumentFilters(portal, current, asoup, ssprops) 
     255                results = portal.portal_catalog.searchResults( 
     256                    query={'path':'/'.join(obj[:-1]),}, 
     257                    id=obj[-1]) 
     258                if results: 
     259                    if results[0].is_folderish: 
     260                        mpath = '%s/index-%s' %(mpath[0], mpath[1]) 
     261                    else: 
     262                        mpath = '%s-%s' %(mpath[0], mpath[1]) 
     263                    if  view not in ssprops.getProperty('non_html_views'): 
     264                        mpath += '.html' 
     265                    self._writeFile(mpath, body)             
     266 
    238267 
    239268    def deployDocumentActions(self, portal, current, dpath, soup, ssprops): 
     
    316345                                                ssprops.getProperty('views_to_add'), 
    317346                                                ssprops.getProperty('non_html_views')) 
    318             print '   %s => %s' %(orig, x['href']) 
     347            # print '   %s => %s' %(orig, x['href']) 
    319348        data = soup.prettify() 
    320349        return self.filterPortalUrl(data, current)