Changeset 18


Ignore:
Timestamp:
11/09/06 12:35:18 (5 years ago)
Author:
christian
Message:

Working wiki-sitemap, admin page is not functional yet

Location:
sitemap-plugin/trunk
Files:
4 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • sitemap-plugin/trunk/setup.py

    r15 r18  
    11#!/usr/bin/env python 
    22 
    3 from setuptools import setup, find_packages 
     3from setuptools import setup 
    44 
    55PACKAGE = 'sitemap' 
     
    1010        author_email = 'christian@wilde-welt.de', 
    1111        url = 'http://voidblog.de/wiki/GoogleSitemap', 
    12         description = 'Google sitemap generator', 
     12        description = 'Various sitemap generators', 
    1313        license='BSD', 
    14         package_dir = { 'sitemap' : 'sitemap' }, 
    1514        packages = ['sitemap'], 
    1615        package_data = { 'sitemap' : [ 'templates/*.cs', ]}, 
  • sitemap-plugin/trunk/sitemap/__init__.py

    r15 r18  
     1import api 
     2import wiki 
    13try: 
    2     from admin import * 
     4    from admin_ui import * 
    35except ImportError: 
    46    pass 
    5 import google 
    6 import admin_ui 
  • sitemap-plugin/trunk/sitemap/admin_ui.py

    r15 r18  
    1 from pkg_resources import resource_filename 
     1from pkg_resources import resource_filename #@UnresolvedImport 
    22from webadmin.web_ui import IAdminPageProvider 
    33from trac.web.chrome import ITemplateProvider 
    4 from trac.perm import IPermissionRequestor 
    54from trac.core import implements 
    65from trac.core import Component 
    76 
     7from api import SitemapController 
    88 
    9 class SitemapAdmin(Component): 
     9class SitemapAdminPage(Component): 
    1010    """ 
    1111        Generates a sitemap file suitable for Google Sitemaps 
    1212    """ 
    1313     
    14     implements(ITemplateProvider, IAdminPageProvider, IPermissionRequestor) 
     14    implements(ITemplateProvider, IAdminPageProvider) 
     15     
     16    priorities = [ 1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1 ] 
     17    frequencies = [ 'never', 'yearly', 'monthly', 'weekly', 'daily', 'hourly', 'always'] 
    1518 
    16     # IPermissionRequestor 
    17     def get_permission_actions(self): 
    18         return ['BLOG_ADMIN'] 
    19  
     19    def _get_field(self, req, name, default_value): 
     20        if name in req.args: 
     21            return req.args[name] 
     22        return default_value 
     23     
    2024    # IAdminPageProvider methods 
    2125    def get_admin_pages(self, req): 
    22         if req.perm.has_permission('BLOG_ADMIN'): 
    23             yield ('general', 'General', 'sitemap', 'Sitemap') 
     26        if req.perm.has_permission('TRAC_ADMIN'): 
     27            yield ('general', 'General', 'sitemap_admin', 'Sitemap') 
    2428 
    2529    def process_admin_request(self, req, cat, page, path_info): 
    26         assert req.perm.has_permission('BLOG_ADMIN') 
     30        assert req.perm.has_permission('TRAC_ADMIN') 
     31        c = SitemapController(self.env) 
    2732 
    28         # add_stylesheet(req, 'blog/css/blog.css') 
    29         # add_stylesheet(req, 'common/css/wiki.css') 
    30         req.hdf['sitemap.url'] = req.base_url + '/sitemap.xml' 
    31         req.hdf['sitemap.priorities'] = [ 1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1 ] 
    32         req.hdf['sitemap.frequencies'] = [ 'monthly', 'weekly', 'daily'] 
     33        if req.method == 'POST': 
     34            if page == 'sitemap': 
     35                if 'save' in req.args: 
     36                    for contributor in c.contributors: 
     37                        name, title = contributor.get_name() #@UnusedVariable 
     38                        contributor.set_configuration( 
     39                                                      self._get_field(req, name + '_priority', contributor.priority), 
     40                                                      self._get_field(req, name + '_frequency', contributor.frequency) 
     41                                                      ) 
     42 
     43        req.hdf['sitemap.data'] = c.get_descriptions() 
     44        req.hdf['sitemap.url'] = c.path 
     45        req.hdf['sitemap.priorities'] = self.priorities 
     46        req.hdf['sitemap.frequencies'] = self.frequencies 
    3347        return 'sitemap_admin.cs', None 
    3448 
  • sitemap-plugin/trunk/sitemap/templates/sitemap_admin.cs

    r16 r18  
    11<form class="mod" method="post"> 
    22<h2>Google Sitemap&trade; settings</h2> 
    3 <p>The URL of the Google sitemap is: <?cs var:sitemap.url ?></p> 
     3<p>What ressources should be included in your sitemap located at <strong><?cs var:sitemap.url ?></strong>?</p> 
    44<table class="listing" id="sitemaplist" style="width:100%;margin-bottom:2em;"> 
    55        <colgroup> 
     
    1111        <thead> 
    1212                <tr> 
    13                         <th class="sel">&nbsp;</th> 
     13                        <th class="sel">Auto-update</th> 
    1414                        <th>Source</th> 
    1515                        <th>Priority</th> 
     
    1818        </thead> 
    1919        <tbody> 
     20                <?cs each:item = sitemap.data ?> 
    2021                <tr> 
    21                         <td><input type="checkbox" name="wiki" value="1"/></td> 
    22                         <td><strong>Wiki pages</strong></td> 
    23                         <td><select> 
     22                        <td align="center"><input type="checkbox" name="handle_<?cs name:item ?>" value="1" <?cs 
     23                        if:item.handle ?> checked="checked" <?cs /if ?> /></td> 
     24                        <td><strong><?cs var:item.title ?></strong></td> 
     25                        <td><select name="<?cs name:item ?>_priority"> 
    2426                <?cs each:priority = sitemap.priorities ?> 
    25                 <option value="<?cs var:priority ?>"><?cs var:priority ?></option> 
     27                <option value="<?cs var:priority ?>" <?cs if:priority == item.priority ?>selected="selected"<?cs /if ?>><?cs var:priority ?></option> 
    2628                <?cs /each ?> 
    2729           </select></td> 
    28            <td><select> 
     30           <td><select name="<?cs name:item ?>_frequency"> 
    2931                <?cs each:freq = sitemap.frequencies ?> 
    30                 <option value="<?cs var:freq ?>"><?cs var:freq ?></option> 
     32                <option value="<?cs var:freq ?>" <?cs if:freq == item.frequency ?>selected="selected"<?cs /if ?>><?cs var:freq ?></option> 
    3133                <?cs /each ?> 
    3234           </select></td> 
    3335                </tr> 
    34                 <tr> 
    35                         <td><input type="checkbox" name="tickets" value="1"/></td> 
    36                         <td><strong>Tickets</strong></td> 
    37                         <td><select> 
    38                 <?cs each:priority = sitemap.priorities ?> 
    39                 <option value="<?cs var:priority ?>"><?cs var:priority ?></option> 
    40                 <?cs /each ?> 
    41            </select></td> 
    42            <td><select> 
    43                 <?cs each:freq = sitemap.frequencies ?> 
    44                 <option value="<?cs var:freq ?>"><?cs var:freq ?></option> 
    45                 <?cs /each ?> 
    46            </select></td> 
    47                 </tr> 
     36                <?cs /each ?> 
    4837        </tbody> 
    4938        <tfoot> 
    5039                <tr> 
    51                         <td colspan="4" style="font-size:80%;">A note on priorities and frequencies: The <strong>priority</strong> will determine 
    52                         how search results will be ranked <em>within your site</em>. It will not influence 
    53                         your Google PageRank&trade;. The priority defaults to 0.5, you can set higher or 
    54                         lower values to distinguish more or less important parts of your site. 
     40                        <td colspan="4" style="font-size:80%;">Note: The <strong>priority</strong> will determine 
     41                        how search results will be ranked <em>within your site</em>, bigger numbers indicating more important parts of your site. 
     42                        It will not influence your Google PageRank&trade;. 
    5543                        <p>The <strong>frequency</strong> indicates how often you plan to update 
    5644                        your site content with respect to this ressource. Setting it to <em>daily</em> doesn't neccessarily mean that Google will pick 
    57                         up your page daily, it's just an indicator.</p></td> 
     45                        up your page daily, it's just an indicator. Even pages marked as <em>never changing</em> (i.e. archives) are visited by the Google crawler 
     46                        every once in a while to detect changes in the page itself.</p></td> 
    5847                </tr> 
    5948        </tfoot> 
    6049</table> 
    61 <fieldset> 
    62         <legend>Notification</legend> 
    63    <div class="field"> 
    64         <input id="cbPingGoogle" type="checkbox" name="pinggoogle" value="1" style="float:left"/> 
    65       <label for="cbPingGoogle" style="display:block; margin-left: 50px;"> 
    66        Do you want to ping the Google Sitemap service each time a wiki 
    67        page is created, updated or deleted? 
    68       </label> 
    69     </div> 
    70 </fieldset> 
    7150<div class="buttons"> 
    72         <input type="submit" value="Save"> 
    73         <input type="submit" value="Save &amp; ping now"> 
     51        <input type="submit" name="save" value="Save"> 
     52        <input type="submit" name="saveping" value="Save &amp; notify now"> 
    7453</div> 
    7554</form> 
Note: See TracChangeset for help on using the changeset viewer.