[Bps-public-commit] App-Changeloggr branch, master, updated. 7bdd40b5c111053cc5ccfd83d86ad077dfb1739d

sartak at bestpractical.com sartak at bestpractical.com
Mon Apr 27 10:13:44 EDT 2009


The branch, master has been updated
       via  7bdd40b5c111053cc5ccfd83d86ad077dfb1739d (commit)
      from  34a7dd569eb02b3e6bb0991f339ad7ec3ce22dcf (commit)

Summary of changes:
 lib/App/Changeloggr/View.pm       |   76 +---------------------------------
 lib/App/Changeloggr/View/Admin.pm |   81 +++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+), 73 deletions(-)
 create mode 100644 lib/App/Changeloggr/View/Admin.pm

- Log -----------------------------------------------------------------
commit 7bdd40b5c111053cc5ccfd83d86ad077dfb1739d
Author: Shawn M Moore <sartak at gmail.com>
Date:   Mon Apr 27 10:10:10 2009 -0400

    Move admin templates and functions to a new view class

diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index 5d67491..bded841 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -4,6 +4,9 @@ use JiftyX::ModelHelpers;
 use strict;
 use warnings;
 
+require App::Changeloggr::View::Admin;
+alias App::Changeloggr::View::Admin under '/';
+
 # No salutation, ever
 template '/salutation' => sub {};
 
@@ -23,15 +26,6 @@ template '/' => page {
     }
 };
 
-template '/create-changelog' => page {
-    my $create = new_action('CreateChangelog', moniker => 'create-changelog');
-    form {
-        render_action $create, ['name'];
-        form_next_page url => '/created-changelog';
-        form_submit(label => 'Create');
-    };
-};
-
 template '/changelog' => page {
     my $changelog = Changelog(name => get('name'));
 
@@ -64,48 +58,6 @@ template '/vote-on-change' => sub {
     }
 };
 
-template '/changelog/admin' => page {
-    my $changelog = Changelog(id => get('id'));
-
-    my $update = $changelog->as_update_action;
-    form {
-        render_action($update);
-        form_submit(label => 'Update');
-    };
-
-    add_changes_to($changelog);
-
-    edit_tags($changelog);
-
-    my $delete = $changelog->as_delete_action;
-    form {
-        render_action($delete);
-        form_next_page(url => '/');
-        form_submit(label => 'Delete');
-    };
-};
-
-sub add_changes_to {
-    my $changelog = shift;
-
-    if ($changelog->changes->count) {
-        p { _("This changelog has %quant(%1,change).", $changelog->changes->count) }
-    }
-
-    my $add_changes = new_action('AddChanges');
-
-    form {
-        render_action($add_changes => ['changes']);
-
-        render_param($add_changes => admin_token => (
-            default_value => $changelog->as_superuser->admin_token,
-            render_as     => 'hidden',
-        ));
-
-        form_submit(label => 'Add');
-    };
-}
-
 sub changelog_summary {
     my $changelog = shift;
 
@@ -166,27 +118,5 @@ sub show_vote_form {
     }
 }
 
-sub edit_tags {
-    my $changelog = shift;
-    my $tags = M("TagCollection", changelog_id => $changelog);
-
-    while (my $tag = $tags->next) {
-        form {
-            my $delete_tag = $tag->as_delete_action;
-            render_action $delete_tag;
-            form_submit(label => $tag->text);
-        }
-    }
-
-    form {
-        my $add_tag = new_action(
-            class     => "CreateTag",
-            arguments => { changelog_id => $changelog->id }
-        );
-        render_action $add_tag;
-        form_submit(label => 'Add Tag');
-    }
-}
-
 1;
 
diff --git a/lib/App/Changeloggr/View/Admin.pm b/lib/App/Changeloggr/View/Admin.pm
new file mode 100644
index 0000000..634d3a9
--- /dev/null
+++ b/lib/App/Changeloggr/View/Admin.pm
@@ -0,0 +1,81 @@
+package App::Changeloggr::View::Admin;
+use Jifty::View::Declare -base;
+use JiftyX::ModelHelpers;
+use strict;
+use warnings;
+
+template '/create-changelog' => page {
+    my $create = new_action('CreateChangelog', moniker => 'create-changelog');
+    form {
+        render_action $create, ['name'];
+        form_next_page url => '/created-changelog';
+        form_submit(label => 'Create');
+    };
+};
+
+template '/changelog/admin' => page {
+    my $changelog = Changelog(id => get('id'));
+
+    my $update = $changelog->as_update_action;
+    form {
+        render_action($update);
+        form_submit(label => 'Update');
+    };
+
+    add_changes_to($changelog);
+
+    edit_tags($changelog);
+
+    my $delete = $changelog->as_delete_action;
+    form {
+        render_action($delete);
+        form_next_page(url => '/');
+        form_submit(label => 'Delete');
+    };
+};
+
+sub add_changes_to {
+    my $changelog = shift;
+
+    if ($changelog->changes->count) {
+        p { _("This changelog has %quant(%1,change).", $changelog->changes->count) }
+    }
+
+    my $add_changes = new_action('AddChanges');
+
+    form {
+        render_action($add_changes => ['changes']);
+
+        render_param($add_changes => admin_token => (
+            default_value => $changelog->as_superuser->admin_token,
+            render_as     => 'hidden',
+        ));
+
+        form_submit(label => 'Add');
+    };
+}
+
+sub edit_tags {
+    my $changelog = shift;
+    my $tags = M("TagCollection", changelog_id => $changelog);
+
+    while (my $tag = $tags->next) {
+        form {
+            my $delete_tag = $tag->as_delete_action;
+            render_action $delete_tag;
+            form_submit(label => $tag->text);
+        }
+    }
+
+    form {
+        my $add_tag = new_action(
+            class     => "CreateTag",
+            arguments => { changelog_id => $changelog->id }
+        );
+        render_action $add_tag;
+        form_submit(label => 'Add Tag');
+    }
+}
+
+1;
+

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list