word: move subpages and includes to word/ directory
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 15 Oct 2021 10:37:55 +0000 (12:37 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 25 Oct 2021 14:33:21 +0000 (16:33 +0200)
.htaccess
word.plp
word/edit.plp [moved from writer.plp with 97% similarity]
word/editor.css [moved from editor.css with 100% similarity]
word/editor.js [moved from writer.js with 100% similarity]
word/quiz.js [moved from wordquiz.js with 100% similarity]
word/quiz.plp [new file with mode: 0644]

index 0c5b23d39f11852d575ed3da12f575af585d6dc7..b23841fb4e9e691abf8613fcc0d0fab4e96d2745 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -1,5 +1,6 @@
 Options        -MultiViews
 DirectoryIndex index.plp
+DirectorySlash Off
 
 RewriteEngine  on
 RewriteBase    /
@@ -16,7 +17,8 @@ RewriteRule ^cc$                     /countries [R=301]
 RewriteRule    ^(digraphs)\.ex(/.*)?$ $1.vim$2
 
 # add .plp if a file exists with .plp appended (topdir only)
-RewriteCond    %{REQUEST_FILENAME}.plp  -f
+RewriteCond    %{REQUEST_FILENAME}     !-f
+RewriteCond    %{DOCUMENT_ROOT}/$1.plp  -f
 RewriteRule    ^/*([^/]+)(.*)           $1.plp$2
 
 # allow browsers to cache for upto a month
index b5a07bf60a9fe9b0f24f49a5df6048a1bfc2ce23..9fa1aaaf87c7b7987c5d0e5c6cf39b45a64d2193 100644 (file)
--- a/word.plp
+++ b/word.plp
@@ -1,22 +1,11 @@
 <(common.inc.plp)><:
 
-if ($Request and $Request =~ s{^edit/?}{}) {
-       Include 'writer.plp';
-       exit;
-}
-
-if ($Request and $Request =~ s{^quiz/?}{}) {
-       Html({
-               raw => <<'EOT',
-<script src="/wordquiz.js"></script>
-<style>
-.wrong {background: red}
-.good {background: green}
-</style>
-EOT
-       });
-       say '<h1>quiz</h1><p id="quiz">test</p>';
-       exit;
+if ($Request and $Request =~ m{\A([^/]+)}) {
+       my $page = "word/$1.plp";
+       if (-e $page) {
+               Include $page;
+               exit;
+       }
 }
 
 my $lang = $get{lang} || 'en';
similarity index 97%
rename from writer.plp
rename to word/edit.plp
index cd2e2bf1d6369529ad52a1186dcb14792ea82f2f..d8de60249c7a54945d048885acc4fb747d87357a 100644 (file)
@@ -1,12 +1,13 @@
-<(common.inc.plp)><:
+<(../common.inc.plp)><:
 
+s{\Aedit(/|\z)}{} for $Request // ();
 Html({
        title => 'words cheat sheet admin',
        version => '1.0',
        nocache => 1,
        raw => <<'EOT',
-<link rel="stylesheet" type="text/css" media="all" href="/editor.css" />
-<script src="/writer.js"></script>
+<link rel="stylesheet" type="text/css" media="all" href="/word/editor.css" />
+<script src="/word/editor.js"></script>
 EOT
 });
 
@@ -20,7 +21,7 @@ my $db = eval {
 } or Abort('Database error', 501, $@);
 
 my $user = eval {
-       my $rootpath = ($ENV{REQUEST_URI} // '/writer') =~ s{(?<!^)/.+}{}r;
+       my $rootpath = '/word/edit';
        if (defined $post{username}) {
                $cookie{login} = EncodeURI(join ':', @post{qw( username pass )});
        }
similarity index 100%
rename from editor.css
rename to word/editor.css
similarity index 100%
rename from writer.js
rename to word/editor.js
similarity index 100%
rename from wordquiz.js
rename to word/quiz.js
diff --git a/word/quiz.plp b/word/quiz.plp
new file mode 100644 (file)
index 0000000..c40a7cd
--- /dev/null
@@ -0,0 +1,12 @@
+<(../common.inc.plp)><:
+
+Html({
+       raw => <<'EOT',
+<script src="/word/quiz.js"></script>
+<style>
+.wrong {background: red}
+.good {background: green}
+</style>
+EOT
+});
+say '<h1>quiz</h1><p id="quiz">test</p>';