aboutsummaryrefslogtreecommitdiff
path: root/lib/WebCoso/Common.pm
diff options
context:
space:
mode:
authordakkar <dakkar@luxion>2008-01-03 20:05:51 +0000
committerdakkar <dakkar@luxion>2008-01-03 20:05:51 +0000
commit409b0fae3968de8b7ec3adfc4840ddad536757ff (patch)
tree182eb0b71053ff9d4bb665bd7fc0173cfe9672c2 /lib/WebCoso/Common.pm
parentMakeMaker! (diff)
downloadWebCoso-409b0fae3968de8b7ec3adfc4840ddad536757ff.tar.gz
WebCoso-409b0fae3968de8b7ec3adfc4840ddad536757ff.tar.bz2
WebCoso-409b0fae3968de8b7ec3adfc4840ddad536757ff.zip
refactoring: TT
git-svn-id: svn://luxion/repos/WebCoso/trunk@326 fcb26f47-9200-0410-b104-b98ab5b095f3
Diffstat (limited to 'lib/WebCoso/Common.pm')
-rw-r--r--lib/WebCoso/Common.pm46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/WebCoso/Common.pm b/lib/WebCoso/Common.pm
new file mode 100644
index 0000000..0680550
--- /dev/null
+++ b/lib/WebCoso/Common.pm
@@ -0,0 +1,46 @@
+package WebCoso::Common;
+
+our $SRCPATH='src';
+our $DSTPATH='dst';
+our $DSTBASEURL='/';
+
+sub langOf {
+ my ($name)=@_;
+ $name=~m{(^|/)document\.([^.]+)(\.|$)} and return $2;
+ return;
+}
+
+sub typeOf {
+ my ($name)=@_;
+ $name=~m{(^|/)document\.[^.]+\.([^.]+\.[^.]+)$} and return $2;
+ return;
+}
+
+sub typedAs {
+ my ($name,$newtype)=@_;
+ $name=~s{(^|/)(document\.[^.]+\.)([^.]+\.[^.]+)$}{$1$2$newtype};
+ return $name;
+}
+
+sub dstUriFor {
+ my ($name,$short)=(@_,1);
+ warn "dstUriFor($name,$short)\n";
+ if ($short) {
+ $name=~s{/[^/]+$}{/};
+ }
+ else {
+ $name=typedAs($name,'html');
+ }
+ $name=~s{^\Q$SRCPATH\E/}{$DSTBASEURL};
+ return $name;
+}
+
+sub isLang {
+ my ($lang,$name)=@_;
+ warn "isLang($lang,$name)\n";
+ return 1 if $name=~m{/$}; # assume that MultiViews on the server will work
+ return 1 if langOf($name) eq $lang;
+ return;
+}
+
+1;