Changeset 4162

Show
Ignore:
Timestamp:
08/21/08 02:38:28 (3 months ago)
Author:
coderanger
Message:

0.11 version.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • newsflashmacro/0.11/newsflash/macro.py

    r1124 r4162  
    33from trac.wiki.api import IWikiMacroProvider 
    44from trac.wiki.formatter import wiki_to_html 
    5  
    6 import inspect 
    7  
    8 __all__ = ['NewsFlashMacro', 'NewsFlashStartMacro', 'NewsFlashEndMacro'] 
    9  
    10 class WikiMacroBase(Component): 
    11     """Abstract base class for wiki macros.""" 
    12  
    13     def get_macros(self): 
    14         """Yield the name of the macro based on the class name.""" 
    15         name = self.__class__.__name__ 
    16         if name.endswith('Macro'): 
    17             name = name[:-5] 
    18         yield name 
    19  
    20     def get_macro_description(self, name): 
    21         """Return the subclass's docstring.""" 
    22         return inspect.getdoc(self.__class__) 
    23  
    24     def render_macro(self, req, name, content): 
    25         raise NotImplementedError 
     5from trac.wiki.macros import WikiMacroBase 
     6from genshi import Markup 
     7from genshi.builder import tag 
     8from pkg_resources import resource_filename 
    269 
    2710class NewsFlashMacro(WikiMacroBase): 
    2811    """Makes a colored box from the contents of the macro.""" 
    2912     
    30     implements(ITemplateProvider, IWikiMacroProvider
     13    implements(ITemplateProvider
    3114     
    3215    # ITemplateProvider 
     
    3518         
    3619    def get_htdocs_dirs(self): 
    37         from pkg_resources import resource_filename 
    38         return [('newsflash', resource_filename(__name__, 'htdocs'))] 
     20        yield 'newsflash', resource_filename(__name__, 'htdocs') 
    3921 
    4022    # IWikiMacroProvier methods 
    41     def render_macro(self, req, name, content): 
    42         add_stylesheet(req, 'newsflash/css/newsflash.css') 
    43         return '<div class="newsflash">%s</div>'%wiki_to_html(content, self.env, req) 
     23    def expand_macro(self, formatter, name, content): 
     24        add_stylesheet(formatter.req, 'newsflash/css/newsflash.css') 
     25        return tag.div(format_to_html(self.env, formatter.context, content), 
     26                       class_='newsflash') 
     27 
    4428 
    4529class NewsFlashStartMacro(WikiMacroBase): 
    4630    """Start a newflash box.""" 
    4731     
    48     implements(IWikiMacroProvider) 
    49      
    50     def render_macro(self, req, name, content): 
    51         add_stylesheet(req, 'newsflash/css/newsflash.css') 
    52         return '<div class="newsflash">' 
     32    def expand_macro(self, formatter, name, content): 
     33        add_stylesheet(formatter.req, 'newsflash/css/newsflash.css') 
     34        return Markup('<div class="newsflash">') 
     35 
    5336 
    5437class NewsFlashEndMacro(WikiMacroBase): 
    5538    """End a newflash box.""" 
    5639     
    57     implements(IWikiMacroProvider) 
    58      
    59     def render_macro(self, req, name, content): 
    60         return '</div>' 
    61          
    62          
     40    def expand_macro(self, formatter, name, content): 
     41        return Markup('</div>') 
     42 
     43 
  • newsflashmacro/0.11/setup.py

    r3416 r4162  
    11#!/usr/bin/env python 
    22# -*- coding: iso-8859-1 -*- 
     3import os 
    34 
    45from setuptools import setup 
     
    67setup( 
    78    name = 'TracNewsFlash', 
    8     version = '0.1', 
     9    version = '1.0', 
    910    packages = ['newsflash'], 
    10     package_data={ 'newsflash' : [ 'htdocs/css/*.css' ] }, 
    11     author = "Noah Kantrowitz", 
    12     author_email = "noah@coderanger.net", 
    13     description = "Make a colored box.", 
    14     license = "BSD", 
    15     keywords = "trac plugin macro news flash", 
    16     url = "http://trac-hacks.org/wiki/NewsFlashMacro", 
     11    package_data = { 'newsflash' : [ 'htdocs/css/*.css' ] }, 
     12    author = 'Noah Kantrowitz', 
     13    author_email = 'noah@coderanger.net', 
     14    description = 'A Trac macro to make a colored box.', 
     15    long_description = open(os.path.join(os.path.dirname(__file__), 'README')).read(), 
     16    license = 'BSD', 
     17    keywords = 'trac plugin macro news flash', 
     18    url = 'http://trac-hacks.org/wiki/NewsFlashMacro', 
     19    classifiers = [ 
     20        'Framework :: Trac', 
     21        'Development Status :: 5 - Production/Stable', 
     22        'Environment :: Web Environment', 
     23        'License :: OSI Approved :: BSD License', 
     24        'Natural Language :: English', 
     25        'Operating System :: OS Independent', 
     26        'Programming Language :: Python', 
     27    ], 
     28     
     29    install_requires = ['Trac'], 
    1730 
    1831    entry_points = {