~ubuntu-branches/ubuntu/feisty/pyblosxom/feisty

« back to all changes in this revision

Viewing changes to contrib/plugins/firstdaydiv.py

  • Committer: Bazaar Package Importer
  • Author(s): Tollef Fog Heen
  • Date: 2005-04-06 18:56:44 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050406185644-t4dg3gqw55bdfu3z
Tags: 1.2-1
* New upstream release (closes: #291726)
  - no contributed plugins any more.  License issues and upstream
    splitting it out of the upstream tarball.
  - No more xmlrpc.py (closes: #227080, #229342)
  - Now actually uses ignore_directories correctly (closes: #271655)
  - Corrected use of hex constants (closes: #274830)
  - Uses $pyblosxom_version in default renderer (closes: #282603)
  - No longer has version number in default config file (closes: #231621)

* Update new upstream URL in welcome.txt
* Update license to the MIT license.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""
2
 
This is my fancy module to add a token which tells us whether we're
3
 
the first day being displayed or not.
4
 
 
5
 
To install:
6
 
 1. Copy this file into your pyblosxom/libs/plugins directory.
7
 
 
8
 
 2. Create a file named date_head.html in your datadir containing::
9
 
 
10
 
    <div class="$dayDivClass">
11
 
    <span class="blosxomDate">$date</span>
12
 
 
13
 
 3. Edit your config.py and add the line::
14
 
 
15
 
    py['firstDayDiv'] = 'blosxomFirstDayDiv'
16
 
 
17
 
 4. That's it.  You're done.
18
 
 
19
 
Questions, comments, concerns?  Email bwinton@latte.ca for help.
20
 
"""
21
 
__author__ = "Blake Winton - bwinton@latte.ca"
22
 
__version__ = "$Id: firstdaydiv.py,v 1.9 2003/04/01 08:52:37 wari Exp $"
23
 
 
24
 
 
25
 
class PyFirstDate:
26
 
    """
27
 
    This class stores the state needed to determine whether we're
28
 
    supposed to return the first-day-div class or the
29
 
    not-the-first-day-div class.
30
 
 
31
 
    @type _dayDiv: string
32
 
    @ivar _dayDiv: The davDiv class to return.
33
 
    @type _count: int
34
 
    @ivar _count: The number of times we've been called (currently 0 or 1)
35
 
    """
36
 
    def __init__(self, request):
37
 
        """
38
 
        Initialize the PyFirstDate class.
39
 
 
40
 
        @type request: L{libs.Request.Request} object
41
 
        @param request: A reference to the L{libs.Request.Request} object.
42
 
        """
43
 
        config = request.getConfiguration()
44
 
        self._dayDiv = config.get("firstDayDiv", "blosxomDayDiv")
45
 
        self._count = 0
46
 
 
47
 
    def __str__(self):
48
 
        """
49
 
        Get a string representing the current state of this
50
 
        object.
51
 
 
52
 
        @rtype: string
53
 
        @return: the user-specified firstDayDiv if it's the first
54
 
                 time we're called, or "blosxomDayDiv" if it's not.
55
 
        """
56
 
        if self._count == 0:
57
 
            self._count = 1
58
 
        else:
59
 
            self._dayDiv = "blosxomDayDiv"
60
 
        return self._dayDiv
61
 
 
62
 
def cb_prepare(args):
63
 
    """
64
 
    Populate the L{libs.Request.Request} with an instance of the
65
 
    L{PyFirstDate} class in the "dayDivClass" key.
66
 
    """
67
 
    request = args["request"]
68
 
 
69
 
    data = request.getData()
70
 
    data["dayDivClass"] = PyFirstDate(request)