[wellwell-devel] [SCM] Interchange wellwell catalog branch, master, updated. 795c813ccbefedcb4a339650fd3513e429defc87
Stefan Hornburg
racke at rt.icdevgroup.org
Wed Jan 6 10:33:32 UTC 2010
via 795c813ccbefedcb4a339650fd3513e429defc87 (commit)
from fb9935d68561e6c77601dbd3b1549d9c24935691 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 795c813ccbefedcb4a339650fd3513e429defc87
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date: Wed Jan 6 11:32:35 2010 +0100
path_redirect plugin added
-----------------------------------------------------------------------
Summary of changes and diff:
plugins/path_redirect/code/path_redirect.tag | 60 ++++++++++++++++++++
.../path_redirect/database/mysql/path_redirect.sql | 7 ++
.../path_redirect.info} | 2 +-
plugins/path_redirect/plugin.cfg | 6 ++
4 files changed, 74 insertions(+), 1 deletions(-)
create mode 100644 plugins/path_redirect/code/path_redirect.tag
create mode 100644 plugins/path_redirect/database/mysql/path_redirect.sql
copy plugins/{discount_gifts/discount_gifts.info => path_redirect/path_redirect.info} (75%)
create mode 100644 plugins/path_redirect/plugin.cfg
diff --git a/plugins/path_redirect/code/path_redirect.tag b/plugins/path_redirect/code/path_redirect.tag
new file mode 100644
index 0000000..1fdcc39
--- /dev/null
+++ b/plugins/path_redirect/code/path_redirect.tag
@@ -0,0 +1,60 @@
+UserTag path_redirect Order function source target
+UserTag path_redirect AddAttr
+UserTag path_redirect Routine <<EOR
+sub {
+ my ($function, $source, $target, $opt) = @_;
+ my (%update_mode, %redirect, $ret);
+
+ $Tag->perl({tables => 'path_redirect'});
+
+ %update_mode = (add => 'insert', modify => 'update', set => 'upsert');
+
+ if (exists $update_mode{$function}) {
+ # in case target exists we have to rewrite it
+ $Db{path_redirect}->query(q{update path_redirect set path_target = '%s' where path_target = '%s'},
+ $target, $source);
+
+ # collect data for redirect
+ $redirect{path_source} = $source;
+ $redirect{path_target} = $target;
+
+ if ($opt->{status_code}) {
+ $redirect{status_code} = $opt->{status_code};
+ }
+ else {
+ $redirect{status_code} = 301;
+ }
+
+ $Db{path_redirect}->set_slice([{dml => $update_mode{$function}}, delete $redirect{path_source}],
+ \%redirect);
+ }
+ elsif ($function eq 'delete') {
+ if ($source) {
+ $ret = $Db{path_redirect}->delete_record($source);
+ }
+ elsif ($target) {
+ $ret = $Db{path_redirect}->query(q{delete from path_redirect where path_target = '%s'}, $target);
+ }
+ else {
+ die "Either source or path required for [path-redirect delete].";
+ }
+ }
+ elsif ($function eq 'check') {
+ my $recref;
+
+ # check whether a redirect applies to the given path
+ unless ($recref = $Db{path_redirect}->row_hash($source)) {
+ return;
+ }
+
+ if ($opt->{bump}) {
+ $Db{path_redirect}->set_field($source, 'last_used', $Tag->time({format => '%s'}));
+ }
+
+ return {url => $recref->{path_target}, status => $recref->{status_code}};
+ }
+ else {
+ die "Unknown function for [path-redirect]: $function.";
+ }
+}
+EOR
diff --git a/plugins/path_redirect/database/mysql/path_redirect.sql b/plugins/path_redirect/database/mysql/path_redirect.sql
new file mode 100644
index 0000000..bcdf1fc
--- /dev/null
+++ b/plugins/path_redirect/database/mysql/path_redirect.sql
@@ -0,0 +1,7 @@
+CREATE TABLE path_redirect (
+ path_source varchar(255) NOT NULL DEFAULT '',
+ path_target varchar(255) NOT NULL DEFAULT '',
+ status_code int NOT NULL DEFAULT 0,
+ last_used int NOT NULL DEFAULT 0,
+ PRIMARY KEY (path_source)
+);
diff --git a/plugins/discount_gifts/discount_gifts.info b/plugins/path_redirect/path_redirect.info
similarity index 75%
copy from plugins/discount_gifts/discount_gifts.info
copy to plugins/path_redirect/path_redirect.info
index 148e86f..ea68689 100644
--- a/plugins/discount_gifts/discount_gifts.info
+++ b/plugins/path_redirect/path_redirect.info
@@ -1,3 +1,3 @@
-name = Discount Gifts
+name = Path Redirect
version = 0.1
author = Stefan Hornburg (Racke) <racke at linuxia.de>
diff --git a/plugins/path_redirect/plugin.cfg b/plugins/path_redirect/plugin.cfg
new file mode 100644
index 0000000..cd4b7e6
--- /dev/null
+++ b/plugins/path_redirect/plugin.cfg
@@ -0,0 +1,6 @@
+Message Loading path_redirect plugin.
+
+Variable CURPLUGIN path_redirect
+include plugins/default.cfg
+
+
hooks/post-receive
--
Interchange wellwell catalog
More information about the wellwell-devel
mailing list