Changeset 6427

Show
Ignore:
Timestamp:
08/20/08 15:41:49 (5 months ago)
Author:
FND
Message:

Plugin Library: support for black- and whitelisting, minor refactoring

per-directory support for black- and whitelisting:
if there is a whitelist file, only those items will be retrieved
if there is a blacklist file, those items will be excluded
whitelist and blacklist files contain one file or directory name per line
whitelist takes precedence over blacklist

blacklist filename is excludeLibrary.txt, whitelist is includeLibrary.txt (tentative)

black- and whitelisting currently do not support wildcards

Location:
Trunk/association/services/pluginLibrary
Files:
13 added
4 modified

Legend:

Unmodified
Added
Removed
  • Trunk/association/services/pluginLibrary/TODO

    r6301 r6427  
    11== Aggregator == 
    22 
    3 * 404 handling 
    4 * SVN black-/whitelist handling 
     3* SVN black-/whitelisting: wildcards support 
     4* logging 
    55* handling of removed plugins (e.g. don't delete, but tag with "disabled"?) 
    66* efficiency enhancements (e.g. caching, deferred processing) 
    7 * logging 
    87 
    98== Search == 
     
    4746* serializers 
    4847* search 
     48 
     49== Misc. == 
     50 
     51* code sanitizing 
     52* refactoring 
  • Trunk/association/services/pluginLibrary/aggregator.py

    r6377 r6427  
    7272                empty = "<html><body><div id='storeArea'>\n</div></body></html>" # XXX: ugly hack; cf. tiddlywiki.TiddlyWiki.getPluginTiddlers() 
    7373                if plugins != empty: 
    74                         store.delete(bag) # XXX: ugly hack? 
    75                         store.put(bag) 
     74                        savePlugins(store, bag) 
    7675                        import_wiki(plugins, bag.name) 
    7776                        return True 
     
    8382                plugins = svn.getPlugins("./", True) 
    8483                if plugins: 
    85                         store.delete(bag) # XXX: ugly hack? 
    86                         store.put(bag) 
     84                        savePlugins(store, bag) 
    8785                        for plugin in plugins: 
    8886                                plugin.bag = bag.name 
     
    109107        store.put(recipe) 
    110108 
     109def savePlugins(store, bag): 
     110        """ 
     111        save repository's plugins to store 
     112 
     113        @param bags: TiddlyWeb bag 
     114        @type  bags: Bag 
     115        @param store: TiddlyWeb store 
     116        @type  store: Store 
     117        @return: None 
     118        """ 
     119        try: # XXX: don't use exception here!? 
     120                store.delete(bag) # XXX: ugly hack? 
     121        except IOError: 
     122                pass 
     123        store.put(bag) 
     124 
    111125# startup 
    112126 
  • Trunk/association/services/pluginLibrary/dirScraper.py

    r6377 r6427  
    1919                """ 
    2020                self.host = addTrailingSlash(host) 
     21                self.blacklist = "excludeLibrary.txt" 
     22                self.whitelist = "includeLibrary.txt" 
    2123 
    2224        def _get(self, url): 
     
    3739                retrieve .js files from directory 
    3840 
     41                if there is a whitelist file, only those items will be retrieved 
     42                if there is a blacklist file, those items will be excluded 
     43                whitelist and blacklist files contain one file or directory name per line 
     44                whitelist takes precedence over blacklist 
     45 
    3946                @param dir: directory (relative path) 
    4047                @type  dir: str 
     
    5057                list = soup.find("ul") 
    5158                items = list.findChildren("li") 
    52                 for item in items: 
    53                         anchor = item.findChild("a") 
    54                         href = anchor["href"] 
    55                         if href == "../": 
     59                uris = [item.findChild("a")["href"] for item in items] 
     60                if self.whitelist in uris: 
     61                        whitelisted = self._get(self.host + dir + self.whitelist).split("\n") 
     62                        uris = [uri.strip() for uri in whitelisted] # XXX: do not strip whitespace!? 
     63                elif self.blacklist in uris: 
     64                        blacklisted = self._get(self.host + dir + self.blacklist).split("\n") 
     65                        uris = [uri.strip() for uri in uris if uri not in blacklisted] # XXX: do not strip whitespace!? 
     66                for uri in uris: 
     67                        if uri == "../": 
    5668                                continue 
    57                         if href.endswith(".js"): # plugin 
     69                        if uri.endswith(".js"): # plugin 
    5870                                plugin = Tiddler() 
    59                                 plugin.title = posixpath.basename(href[:-3]) 
     71                                plugin.title = posixpath.basename(uri[:-3]) 
    6072                                plugin.tags = "systemConfig" # XXX: should be list; cf. aggregator.getPlugins() 
    61                                 plugin.text = self._get(self.host + dir + href) 
     73                                plugin.text = self._get(self.host + dir + uri) 
    6274                                plugins.append(plugin) 
    63                         elif href.endswith("/") and recursive: # directory 
    64                                 plugins.extend(self.getPlugins(dir + href)) 
     75                        elif uri.endswith("/") and recursive: # directory -- XXX: potential for infinite loop? 
     76                                plugins.extend(self.getPlugins(dir + uri)) 
    6577                return plugins 
    6678 
  • Trunk/association/services/pluginLibrary/repos.lst

    r6377 r6427  
    44#http://www.tiddlytools.com | TiddlyWiki | TiddlyTools 
    55#http://devpad.tiddlyspot.com | TiddlyWiki | FND's DevPad 
    6 http://svn.tiddlywiki.org/Trunk/association/plugins | SVN | Community Plugins 
     6#http://svn.tiddlywiki.org/Trunk/association/plugins | SVN | Community Plugins 
     7 
     8http://svn.tiddlywiki.org/Trunk/association/pluginLibrary/test | SVN | Test