Thread: [Codestriker-commits] CVS update: codestriker/lib/Codestriker/Action ListTopics.pm
Brought to you by:
sits
From: <si...@us...> - 2008-06-20 04:27:18
|
User: sits Date: 08/06/19 21:27:16 Modified: lib/Codestriker/Http Template.pm lib/Codestriker/Action ListTopics.pm Added: template/en/default listtopics.xml.tmpl Log: Commit from Rob Webset - ability to retrieve list of topics in xml format for reporting purposes: https://sourceforge.net/tracker/?func=detail&atid=429862&aid=1904057&group_id=41136 Index: listtopics.xml.tmpl =================================================================== RCS file: listtopics.xml.tmpl diff -N listtopics.xml.tmpl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ listtopics.xml.tmpl 20 Jun 2008 04:27:15 -0000 1.1 @@ -0,0 +1,27 @@ +Content-type: text/plain + +<?xml version="1.0" encoding="UTF-8"?> +<topics> + [% FOREACH topic = alltopics %] + <topic> + <topicid>[% topic.topicid %]</topicid> + <title>[% topic.title %]</title> + <description>[% topic.description %]</description> + <topic_state>[% topic.topic_state %]</topic_state> + <topic_state_id>[% topic.topic_state_id %]</topic_state_id> + <author>[% topic.author %]</author> + <cc>[% topic.cc %]</cc> + <reviewers>[% topic.reviewers %]</reviewers> + <project_name>[% topic.project_name %]</project_name> + <project_id>[% topic.project_id %]</project_id> + [%# Make sure we remove any password from the end of the repository %] + <repository>[% topic.repository.split( ';' ).0 %]</repository> + <module>[% topic.module %]</module> + <start_tag>[% topic.start_tag %]</start_tag> + <end_tag>[% topic.end_tag %]</end_tag> + <bug_ids>[% topic.bug_ids %]</bug_ids> + <version>[% topic.version %]</version> + <creation_ts>[% topic.creation_ts %]</creation_ts> + </topic> + [% END %] +</topics> Index: Template.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Template.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- Template.pm 7 Mar 2007 03:03:40 -0000 1.17 +++ Template.pm 20 Jun 2008 04:27:15 -0000 1.18 @@ -16,10 +16,16 @@ # Create a new template. sub new($$) { - my ($type, $name) = @_; + my ($type, $name, $ttype) = @_; my $self = {}; $self->{name} = $name; + + if (defined $ttype && $ttype ne "") { + $self->{type} = $ttype; + } else { + $self->{type} = "html"; + } # Template configuration. my $config = { @@ -123,7 +129,7 @@ $vars->{'doc_url'} = $url_builder->doc_url(); my $data = ""; - my $rc = $self->{template}->process($self->{name} . ".html.tmpl", + my $rc = $self->{template}->process($self->{name} . "." . $self->{type} . ".tmpl", $vars, \$data); die $self->{template}->error() if (!defined $rc || $rc == 0); print $data; Index: ListTopics.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ListTopics.pm,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- ListTopics.pm 23 Feb 2008 02:28:09 -0000 1.31 +++ ListTopics.pm 20 Jun 2008 04:27:15 -0000 1.32 @@ -13,10 +13,24 @@ use Codestriker::Http::Template; use Codestriker::Model::Topic; -# If the input is valid, list the appropriate topics. +# find out which format to display the list in sub process($$$) { my ($type, $http_input, $http_response) = @_; + my $format = $http_input->get('format'); + + if (defined $format && $format eq "xml") { + process_xml($type, $http_input, $http_response); + } else { + process_default($type, $http_input, $http_response); + } +} + + +# If the input is valid, list the appropriate topics. +sub process_default($$$) { + my ($type, $http_input, $http_response) = @_; + my $query = $http_response->get_query(); # Check if this action is allowed. @@ -226,6 +240,36 @@ $http_response->generate_footer(); } + +# If the input is valid, display the topic. +sub process_xml($$$) { + my ($self, $http_input, $http_response) = @_; + + my $sbugid = $http_input->get('sbugid') || ""; + my $sauthor = $http_input->get('sauthor') || ""; + my $sreviewer = $http_input->get('sreviewer') || ""; + my $scc = $http_input->get('scc') || ""; + my $stext = $http_input->get('stext') || ""; + + my @sort_order; + my @topics = Codestriker::Model::Topic->query($sauthor, + $sreviewer, + $scc, + $sbugid, + "", "", + $stext, + "", "", "", "", "", + \@sort_order ); + + my $var; + $var->{ alltopics } = \@topics; + + # Fire the template for generating the view topic screen. + my $template = Codestriker::Http::Template->new("listtopics", "xml"); + $template->process($var); +} + + # Process the input and return the parts that will feed into the topic # list query. Returns in the same order that the topic query function # takes them. |
From: <si...@us...> - 2008-06-23 22:40:19
|
User: sits Date: 08/06/23 15:40:18 Modified: lib/Codestriker/Action ListTopics.pm Log: Make sure the URL to the topic is set correctly. Index: ListTopics.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ListTopics.pm,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- ListTopics.pm 20 Jun 2008 04:27:15 -0000 1.32 +++ ListTopics.pm 23 Jun 2008 22:40:18 -0000 1.33 @@ -133,8 +133,7 @@ my $template_topic = {}; $template_topic->{'view_topic_url'} = - $url_builder->view_url($topic->{topicid}, -1, $mode, - $Codestriker::default_topic_br_mode); + $url_builder->view_url($topic->{topicid}, -1, $mode); $template_topic->{'description'} = $topic->{description}; |
From: <si...@us...> - 2008-08-30 03:30:44
|
User: sits Date: 08/08/29 20:30:39 Modified: lib/Codestriker/Action ListTopics.pm Log: Get list topics working with nice URLs. Index: ListTopics.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ListTopics.pm,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- ListTopics.pm 15 Aug 2008 06:30:39 -0000 1.36 +++ ListTopics.pm 30 Aug 2008 03:30:39 -0000 1.37 @@ -292,7 +292,7 @@ my $sbody = $http_input->get('sbody') || 0; my $sfilename = $http_input->get('sfilename') || 0; my $projectid = $http_input->get('projectid'); - + # If $sproject has been set to -1, then retrieve the value of the projectid # from the cookie as the project search value. This is done to facilate # integration with other systems, which jump straight to this URL, and @@ -301,8 +301,8 @@ $sproject = (defined $projectid) ? $projectid : ""; } - # Only show open topics if codestriker.pl was run without parameters. - if (defined($http_input->{query}->param) == 0 || !defined($sstate)) { + # Default to show open topics if sstate is not defined. + if (!defined($sstate)) { $sstate = 0; } @@ -327,6 +327,7 @@ my $topic_sort_change = $http_input->get('topic_sort_change'); my $topicsort = $http_input->get('topicsort'); + return () unless defined $topicsort; my @sort_order = split(/,/,$topicsort); # this is always from the cookie. if (defined $topic_sort_change && $topic_sort_change ne "") { |
From: <si...@us...> - 2008-09-09 04:58:42
|
User: sits Date: 08/09/08 21:58:41 Modified: lib/Codestriker/Action ListTopics.pm Log: Handle list topics properly if sstate is not set. Index: ListTopics.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ListTopics.pm,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- ListTopics.pm 6 Sep 2008 03:31:06 -0000 1.39 +++ ListTopics.pm 9 Sep 2008 04:58:41 -0000 1.40 @@ -305,7 +305,7 @@ } # Default to show open topics if sstate is not defined. - if (!defined($sstate)) { + if (!defined($sstate) || $sstate eq "") { $sstate = 0; } |