Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix tags update when server_root is set

November::Tags.new() now takes a config param, instead of always
creating its own new Config object.
  • Loading branch information...
commit 4d3f6b50cb7365d862f1912ac7f04fcdf8d3c0ac 1 parent e68e5b0
@softmoth softmoth authored
View
10 lib/November.pm
@@ -60,7 +60,7 @@ class November does November::Session does November::Cache {
}
# TODO: we need plugin system (see topics in mail-list)
- my $t = November::Tags.new;
+ my $t = November::Tags.new(:$.config);
my $title = $page.trans( ['_'] => [' '] );
@@ -127,7 +127,7 @@ class November does November::Session does November::Cache {
self.remove-cache-entry( $page );
# TODO: we need plugin system (see topics in mail-list)
- my $t = November::Tags.new();
+ my $t = November::Tags.new(:$.config);
$t.update_tags($page, $tags);
$.cgi.redirect('/view/' ~ $page );
@@ -135,7 +135,7 @@ class November does November::Session does November::Cache {
}
# TODO: we need plugin system (see topics in mail-list)
- my $t = November::Tags.new;
+ my $t = November::Tags.new(:$.config);
self.response( 'edit.tmpl',
{
PAGE => $page,
@@ -160,7 +160,7 @@ class November does November::Session does November::Cache {
);
# Should really use the $tags parameter here, this will do for now...
- #my $t = November::Tags.new();
+ #my $t = November::Tags.new(:$.config);
#my $tags = $t.tags_parse( $tags );
self.response( 'edit.tmpl',
@@ -341,7 +341,7 @@ class November does November::Session does November::Cache {
method list_all_pages {
- my $t = November::Tags.new();
+ my $t = November::Tags.new(:$.config);
my %params;
%params<TAGS> = $t.all_tags if $t;
View
14 lib/November/Tags.pm
@@ -3,11 +3,15 @@ use v6;
use November::Config;
class November::Tags {
- my $server_root = November::Config.new.server_root;
- # TODO Nasty hack to enable testing to use different paths
- has $.page_tags_path is rw = $server_root ~ 'data/page_tags/';
- has $.tags_count_path is rw = $server_root ~ 'data/tags_count';
- has $.tags_index_path is rw = $server_root ~ 'data/tags_index';
+ has $.page_tags_path is rw;
+ has $.tags_count_path is rw;
+ has $.tags_index_path is rw;
+
+ submethod BUILD(:$config = November::Config.new) {
+ $.page_tags_path = $config.server_root ~ 'data/page_tags/';
+ $.tags_count_path = $config.server_root ~ 'data/tags_count';
+ $.tags_index_path = $config.server_root ~ 'data/tags_index';
+ }
method update_tags($_: Str $page, Str $new_tags) {
my $old_tags = .read_page_tags($page).chomp;
View
8 t/tags/norm_counts.t
@@ -5,6 +5,11 @@ plan 3;
use November::Tags;
+use November::Config;
+my $config = November::Config.new(
+ server_root => 't/tags/',
+);
+
role Testing {
method clear {
my $c = {};
@@ -12,8 +17,7 @@ role Testing {
}
}
-my $t = November::Tags.new does Testing;
-$t.tags_count_path = 't/tags/data/tags_count';
+my $t = November::Tags.new(:$config) does Testing;
$t.clear;
is( ($t.norm_counts).perl, '{}', 'With empty tags_count norm_counts produce empty Hash' );
View
7 t/tags/update_tags.t
@@ -5,6 +5,11 @@ plan 8;
use November::Tags;
+use November::Config;
+my $config = November::Config.new(
+ server_root => 't/tags/',
+);
+
role Testing {
method clear ($_:) {
my $c = {};
@@ -15,7 +20,7 @@ role Testing {
}
}
-my $t = November::Tags.new does Testing;
+my $t = November::Tags.new(:$config) does Testing;
$t.page_tags_path = 't/tags/data/page_tags/';
$t.tags_count_path = 't/tags/data/tags_count';
$t.tags_index_path = 't/tags/data/tags_index';
Please sign in to comment.
Something went wrong with that request. Please try again.