Show
Ignore:
Timestamp:
01/30/11 12:14:27 (2 years ago)
Author:
mbutscher
Message:

branches/stable-2.0:
2.0final

branches/mbutscher/work:
2.1beta11
* Option to show iframe content from external

sources inside the HTML IE preview

* Remove plus signs in front of headings in page

structure view, use indentation instead

* Translating of menu accelerators enhanced

(scanning for all 16 bit unicode characters)

* Internal, index search: Store a format number for

search index and rebuild index if number doesn't
match the number for current WikidPad version

* Internal: Moved system detection functions from

"Configuration" to new module "SystemInfo?", made
more imports relative

* Experimental, Windows: Option to control if to

scroll control under pointer with mouse wheel on
Windows (instead of focused control)

* Reordered some options (on global "Advanced" page

and below)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/mbutscher/work/lib/pwiki/wikidata/WikiDataManager.py

    r245 r247  
    2020from .. import ParseUtilities 
    2121from ..StringOps import mbcsDec, re_sub_escape, pathEnc, pathDec, \ 
    22         unescapeWithRe, strToBool 
     22        unescapeWithRe, strToBool, pathnameFromUrl, urlFromPathname, \ 
     23        relativeFilePath 
    2324from ..DocPages import DocPage, WikiPage, FunctionalPage, AliasWikiPage 
    2425# from ..timeView.Versioning import VersionOverview 
     
    341342            dataDir = os.path.join(os.path.dirname(wikiConfigFilename), dataDir) 
    342343 
    343 #         dataDir = mbcsDec(os.path.abspath(dataDir), "replace")[0] 
    344344        dataDir = pathDec(os.path.abspath(dataDir)) 
    345  
    346 #         self.wikiConfigFilename = wikiConfigFilename 
    347345 
    348346        if not dbtype: 
     
    395393        self.wikiPageDict = WeakValueDictionary() 
    396394        self.funcPageDict = WeakValueDictionary() 
    397  
     395         
    398396        self.updateExecutor = SingleThreadExecutor(4) 
    399397        self.pageRetrievingLock = TimeoutRLock(Consts.DEADBLOCKTIMEOUT) 
     
    473471             
    474472        self.updateExecutor.start() 
    475          
     473 
     474        if self.isSearchIndexEnabled() and self.getWikiConfig().getint( 
     475                "main", "indexSearch_formatNo", 1) != Consts.SEARCHINDEX_FORMAT_NO: 
     476            # Search index rebuild needed 
     477            # Remove old search index and lower meta data state. 
     478            # The following pushDirtyMetaDataUpdate() will start rebuilding 
     479 
     480            wikiData = self.getWikiData() 
     481 
     482            wikiData.commit() 
     483            finalState = Consts.WIKIWORDMETADATA_STATE_SYNTAXPROCESSED 
     484 
     485            for wikiWord in wikiData.getWikiWordsForMetaDataState( 
     486                    finalState, "<"): 
     487                wikiData.setMetaDataState(wikiWord, finalState) 
     488 
     489            wikiData.commit() 
     490            self.removeSearchIndex() 
     491 
    476492        self.pushDirtyMetaDataUpdate() 
    477493         
     
    714730            wikiConfig.setWriteAccessDenied(False) 
    715731            wikiConfig.set("main", "wiki_readOnly", "False") 
     732 
     733 
     734 
     735    def makeRelUrlAbsolute(self, relurl): 
     736        """ 
     737        Return the absolute file: URL for a rel: URL 
     738        """ 
     739        relpath = pathnameFromUrl(relurl[6:], False) 
     740 
     741        url = u"file:" + urlFromPathname( 
     742                os.path.abspath(os.path.join(os.path.dirname( 
     743                        self.getWikiConfigPath()), relpath))) 
     744 
     745        return url 
     746 
     747 
     748    def makeAbsPathRelUrl(self, absPath): 
     749        """ 
     750        Return the rel: URL for an absolute file path or None if 
     751        a relative URL can't be created 
     752        """ 
     753        locPath = self.getWikiConfigPath() 
     754 
     755        if locPath is None: 
     756            return None 
     757 
     758        locPath = os.path.dirname(locPath) 
     759        relPath = relativeFilePath(locPath, absPath) 
     760        if relPath is None: 
     761            return None 
     762 
     763        return u"rel://" + urlFromPathname(relPath) 
     764 
    716765 
    717766 
     
    924973                # No active page available 
    925974                realWikiWord = self.getUnAliasedWikiWordOrAsIs(wikiWord) 
    926 #                 print "--_getWikiPageNoErrorNoCache13", repr((wikiWord, realWikiWord)) 
    927975                if wikiWord == realWikiWord: 
    928976                    # no alias 
     
    16071655            resultList = s.search(q, limit=None) 
    16081656             
    1609 #             docnumList = [(rd.docnum, rd["unifName"]) for rd in resultList] 
    1610 #              
    1611 #             docnumList.sort() 
    1612 #             docpp = "\n".join(["%3i %s" % rd for rd in docnumList]) 
    1613 #  
    1614 #             print "--docResults" 
    1615 #             print docpp.encode("mbcs", "replace") 
    1616  
    16171657            result = [rd["unifName"][9:] for rd in resultList 
    16181658                    if rd["unifName"].startswith(u"wikipage/")] 
     
    16631703 
    16641704    def removeSearchIndex(self): 
    1665         if self.isSearchIndexEnabled(): 
    1666             raise InternalError("Calling removeSearchIndex() while index is enabled") 
     1705#         if self.isSearchIndexEnabled(): 
     1706#             raise InternalError("Calling removeSearchIndex() while index is enabled") 
    16671707         
    16681708        p = self.updateExecutor.pause(wait=True) 
     
    16801720            shutil.rmtree(indexPath, ignore_errors=True) 
    16811721 
     1722        self.getWikiConfig().set("main", "indexSearch_formatNo", u"0") 
     1723 
    16821724 
    16831725    def getSearchIndex(self, clear=False): 
     
    17041746 
    17051747            self.whooshIndex = whoosh.index.open_dir(indexPath) 
     1748             
     1749            self.getWikiConfig().set("main", "indexSearch_formatNo", 
     1750                    unicode(Consts.SEARCHINDEX_FORMAT_NO)) 
    17061751 
    17071752        self.whooshIndex = self.whooshIndex.refresh() 
     1753 
    17081754        return self.whooshIndex 
    17091755