Skip to content

Commit

Permalink
Fix package data, resources paths, Move ITemplateProvider methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lexqt committed Apr 9, 2012
1 parent 81a742c commit 9feea69
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 35 deletions.
15 changes: 14 additions & 1 deletion ganttcalendar/api.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from datetime import date
from pkg_resources import resource_filename

from trac.core import Component
from trac.core import Component, implements
from trac.config import IntOption
from trac.util.translation import domain_functions

from trac.web.chrome import ITemplateProvider


__all__ = ['TracGanttCalendar']

Expand Down Expand Up @@ -49,9 +51,20 @@ def add_months(year, month, months):

class TracGanttCalendar(Component):

implements(ITemplateProvider)

first_day = IntOption('ganttcalendar', 'first_day', '0',
doc='Begin of week: 0 == Sunday, 1 == Monday')

def __init__(self):
locale_dir = resource_filename(__name__, 'locale')
add_domain(self.env.path, locale_dir)

# ITemplateProvider

def get_templates_dirs(self):
return [resource_filename(__name__, 'templates')]

def get_htdocs_dirs(self):
return [('ganttcalendar', resource_filename(__name__, 'htdocs'))]

14 changes: 7 additions & 7 deletions ganttcalendar/templates/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@
<input type="submit" value="${_('Update')}" />
<label ACCESSKEY="M" onclick="form.year.value = ${date.today().year}; form.month.value = ${date.today().month}; form.day.value = ${date.today().day}; form.submit();"/>
<py:choose>
<input py:when="not weekly" type="image" ACCESSKEY="I" onclick="form.weekly.value = 1" src="${href.chrome('ticketcalendar/img/zoom_in.png')}" alt="${_('Zoom In')}"/>
<input py:otherwise="" type="image" disabled="disabled" src="${href.chrome('ticketcalendar/img/zoom_in_g.png')}"/>
<input py:when="not weekly" type="image" ACCESSKEY="I" onclick="form.weekly.value = 1" src="${href.chrome('ganttcalendar/img/zoom_in.png')}" alt="${_('Zoom In')}"/>
<input py:otherwise="" type="image" disabled="disabled" src="${href.chrome('ganttcalendar/img/zoom_in_g.png')}"/>
</py:choose>
<py:choose>
<input py:when="weekly" type="image" ACCESSKEY="K" onclick="form.weekly.value = 0;" src="${href.chrome('ticketcalendar/img/zoom_out.png')}" alt="${_('Zoom Out')}"/>
<input py:otherwise="" type="image" disabled="disabled" src="${href.chrome('ticketcalendar/img/zoom_out_g.png')}"/>
<input py:when="weekly" type="image" ACCESSKEY="K" onclick="form.weekly.value = 0;" src="${href.chrome('ganttcalendar/img/zoom_out.png')}" alt="${_('Zoom Out')}"/>
<input py:otherwise="" type="image" disabled="disabled" src="${href.chrome('ganttcalendar/img/zoom_out_g.png')}"/>
</py:choose>
<input name="day" type="hidden" value="${current.day}" />
<input name="weekly" type="hidden" value="${weekly}" />
Expand Down Expand Up @@ -107,7 +107,7 @@
<py:for each="c in range(len(days[mday]['ticket']))">
<div class="ticket" py:with="t=tickets[days[mday]['ticket'][c]['num']]">
<a class="tip" href="${req.href.ticket()}/${t['id']}">
<img src="${href.chrome('ticketcalendar/img/arrow_'+days[mday]['ticket'][c]['img']+'.png')}" alt="+" />
<img src="${href.chrome('ganttcalendar/img/arrow_'+days[mday]['ticket'][c]['img']+'.png')}" alt="+" />
<s py:strip="t['status']!='closed'"><span class="type">${t['type']}</span>#${t['id']}</s>:${t['summary']}
<span class="popup">
<br />
Expand All @@ -132,10 +132,10 @@
<py:for each="c in range(len(days[mday]['milestone']))" py:if="'MILESTONE_VIEW' in req.perm">
<div class="ticket" py:with="m=milestones[days[mday]['milestone'][c]]">
<a class="tip" href="${req.href.milestone()}/${m['name']}">
<s py:strip="m['completed']!=True"><img src="${href.chrome('ticketcalendar/img/package.png')}" />${m['name']}</s>
<s py:strip="m['completed']!=True"><img src="${href.chrome('ganttcalendar/img/package.png')}" />${m['name']}</s>
<span class="popup">
<br />
<img src="${href.chrome('ticketcalendar/img/package.png')}" />${m['name']}<br />
<img src="${href.chrome('ganttcalendar/img/package.png')}" />${m['name']}<br />
<br />
<strong>Due</strong>: ${m['due'].strftime(date_format)}<br />
<pre> ${m['description']}</pre>
Expand Down
10 changes: 5 additions & 5 deletions ganttcalendar/templates/gantt.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@
<input type="submit" value="${_('Update')}" />
<label ACCESSKEY="M" onclick="form.year.value = ${date.today().year}; form.month.value = ${date.today().month}; form.submit();"/>
<py:choose>
<input py:when="zoom &gt; 1" type="image" ACCESSKEY="I" onclick="form.zoom.value = ${zoom-1};" src="${href.chrome('ganttchart/img/zoom_in.png')}" alt="${_('Zoom In')}"/>
<input py:otherwise="" type="image" disabled="disabled" src="${href.chrome('ganttchart/img/zoom_in_g.png')}"/>
<input py:when="zoom &gt; 1" type="image" ACCESSKEY="I" onclick="form.zoom.value = ${zoom-1};" src="${href.chrome('ganttcalendar/img/zoom_in.png')}" alt="${_('Zoom In')}"/>
<input py:otherwise="" type="image" disabled="disabled" src="${href.chrome('ganttcalendar/img/zoom_in_g.png')}"/>
</py:choose>
<label style="cursor: pointer;" ACCESSKEY="N" onclick="form.zoom.value = ${normal}; form.submit();">${zoom}</label>
<py:choose>
<input py:when="zoom &lt; 6" type="image" ACCESSKEY="K" onclick="form.zoom.value = ${zoom+1};" src="${href.chrome('ganttchart/img/zoom_out.png')}" alt="${_('Zoom Out')}"/>
<input py:otherwise="" type="image" disabled="disabled" src="${href.chrome('ganttchart/img/zoom_out_g.png')}"/>
<input py:when="zoom &lt; 6" type="image" ACCESSKEY="K" onclick="form.zoom.value = ${zoom+1};" src="${href.chrome('ganttcalendar/img/zoom_out.png')}" alt="${_('Zoom Out')}"/>
<input py:otherwise="" type="image" disabled="disabled" src="${href.chrome('ganttcalendar/img/zoom_out_g.png')}"/>
</py:choose>
<input name="zoom" type="hidden" value="${zoom}" />
</td>
Expand Down Expand Up @@ -274,7 +274,7 @@
<a py:strip="t['milestone']=='*'" class="tip" href="${req.href.milestone()}/${t['milestone']}">${t['milestone']}
<span py:if="t['milestone']!='*'" py:with="m=milestones[t['milestone']]" class="popup">
<br/>
<img src="${href.chrome('ganttchart/img/package.png')}" />${t['milestone']}<br/>
<img src="${href.chrome('ganttcalendar/img/package.png')}" />${t['milestone']}<br/>
<br/>
<strong>Due</strong>: <span py:if="m.due">${m.due.strftime(date_format)}</span><br/>
<pre> ${m.description}</pre>
Expand Down
12 changes: 3 additions & 9 deletions ganttcalendar/ticketcalendar.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import calendar
from datetime import date, timedelta
from pkg_resources import resource_filename

from genshi.builder import tag

from trac.core import Component, implements
from trac.web import IRequestHandler
from trac.web.chrome import INavigationContributor, ITemplateProvider, add_stylesheet
from trac.web.chrome import INavigationContributor, add_stylesheet
from trac.config import BoolOption

from trac.ticket.api import TicketSystem, convert_field_value
Expand All @@ -23,7 +22,7 @@

class TicketCalendar(Component):

implements(INavigationContributor, IRequestHandler, ITemplateProvider)
implements(INavigationContributor, IRequestHandler)

show_weekly_view = BoolOption('ganttcalendar', 'show_weekly_view', 'false',
doc='Set weekly view as default in calendar.')
Expand Down Expand Up @@ -216,12 +215,7 @@ def process_request(self, req):
'show_my_ticket': show_my_ticket, 'show_closed_ticket': show_closed_ticket, 'selected_milestone': selected_milestone,
'_':_,'date_format':date_format, 'month_tbl': month_tbl, 'weekdays': weekdays}

add_stylesheet(req, 'ticketcalendar/css/calendar.css')
add_stylesheet(req, 'ganttcalendar/css/calendar.css')

return 'calendar.html', data, None

def get_templates_dirs(self):
return [resource_filename(__name__, 'templates')]

def get_htdocs_dirs(self):
return [('ticketcalendar', resource_filename(__name__, 'htdocs'))]
15 changes: 3 additions & 12 deletions ganttcalendar/ticketgantt.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import calendar
from datetime import date, timedelta
from genshi.builder import tag
from pkg_resources import resource_filename

from trac.core import Component, implements, TracError
from trac.config import IntOption, BoolOption
from trac.util.datefmt import parse_date_only

from trac.web import IRequestHandler
from trac.web.chrome import INavigationContributor, ITemplateProvider, \
from trac.web.chrome import INavigationContributor, \
add_stylesheet, add_warning

from trac.ticket.api import TicketSystem, convert_field_value
Expand All @@ -25,7 +24,7 @@

class TicketGanttChart(Component):

implements(INavigationContributor, IRequestHandler, ITemplateProvider)
implements(INavigationContributor, IRequestHandler)

show_ticket_summary = BoolOption('ganttcalendar', 'show_ticket_summary', 'false',
doc='Show ticket summary at gantchart bar')
Expand Down Expand Up @@ -268,18 +267,10 @@ def process_request(self, req):
'_':_,
}

add_stylesheet(req, 'ganttchart/css/chart.css')
add_stylesheet(req, 'ganttcalendar/css/chart.css')

return 'gantt.html', data, None

# ITemplateProvider

def get_templates_dirs(self):
return [resource_filename(__name__, 'templates')]

def get_htdocs_dirs(self):
return [('ganttchart', resource_filename(__name__, 'htdocs'))]

#

def adjust( self, x_start, x_end, term):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
license = "New BSD",

entry_points={'trac.plugins': '%s = %s' % (PACKAGE, PACKAGE)},
package_data={PACKAGE: ['templates/*.html','htdocs/img/*','htdocs/js/*', 'locale/*.*','locale/*/LC_MESSAGES/*.*']},
package_data={PACKAGE: ['templates/*.html','htdocs/img/*', 'htdocs/js/*', 'htdocs/css/*', 'locale/*.*','locale/*/LC_MESSAGES/*.*']},
**extra)

#### AUTHORS ####
Expand Down

0 comments on commit 9feea69

Please sign in to comment.