George S. Baugh 5 лет назад
Родитель
Сommit
7d16035615
4 измененных файлов с 30 добавлено и 38 удалено
  1. 19 17
      lib/Trog/Routes/HTML.pm
  2. 0 9
      www/templates/config.tx
  3. 2 10
      www/templates/mbengine.tx
  4. 9 2
      www/templates/sysbar.tx

+ 19 - 17
lib/Trog/Routes/HTML.pm

@@ -67,13 +67,17 @@ our %routes = (
         auth     => 1,
         callback => \&Trog::Routes::HTML::post,
     },
-    '/posts/(.*)' => {
+    '/post/(.*)' => {
         method   => 'GET',
         auth     => 1,
+        callback => \&Trog::Routes::HTML::post,
+        captures => ['id'],
+    },
+    '/posts/(.*)' => {
+        method   => 'GET',
         callback => \&Trog::Routes::HTML::posts,
         captures => ['id'],
     },
-
     '/posts' => {
         method   => 'GET',
         callback => \&Trog::Routes::HTML::posts,
@@ -94,13 +98,20 @@ our %routes = (
     },
 );
 
-# Build aliases for /post with extra data
+# Build aliases for /posts and /post with extra data
 my @post_aliases = qw{news blog image video audio about files series};
 @routes{map { "/$_" } @post_aliases} = map { my %copy = %{$routes{'/posts'}}; $copy{data}{tag} = [$_]; \%copy } @post_aliases;
 
-# Build aliases for /post/(.*) with extra data
-@routes{map { "/$_/(.*)" } @post_aliases} = map { my %copy = %{$routes{'/posts/(.*)'}}; \%copy } @post_aliases;
+#TODO clean this up so we don't need _build_post_type
+@routes{map { "/post/$_" } qw{image video audio files}} = map { my %copy = %{$routes{'/post'}}; $copy{data}{tag} = [$_]; $copy{data}{type} = 'file'; \%copy } qw{image video audio files};
+$routes{'/post/news'}    = { method => 'GET', auth => 1, callback => \&Trog::Routes::HTML::post, data => { tag => ['news'],    type => 'microblog' } };
+$routes{'/post/blog'}    = { method => 'GET', auth => 1, callback => \&Trog::Routes::HTML::post, data => { tag => ['blog'],    type => 'blog'      } };
+$routes{'/post/about'}   = { method => 'GET', auth => 1, callback => \&Trog::Routes::HTML::post, data => { tag => ['profile'], type => 'profile'   } };
+$routes{'/post/series'}  = { method => 'GET', auth => 1, callback => \&Trog::Routes::HTML::post, data => { tag => ['series'],  type => 'series'    } };
 
+# Build aliases for /posts/(.*) and /post/(.*) with extra data
+@routes{map { "/$_/(.*)" } @post_aliases} = map { my %copy = %{$routes{'/posts/(.*)'}}; \%copy } @post_aliases;
+@routes{map { "/$_/(.*)" } @post_aliases} = map { my %copy = %{$routes{'/post/(.*)'}}; \%copy } @post_aliases;
 
 # Grab theme routes
 my $themed = 0;
@@ -284,11 +295,8 @@ sub config ($query, $input, $render_cb) {
     #NOTE: we are relying on this to skip the ACL check with 'admin', this may not be viable in future?
     return forbidden($query, $input, $render_cb) unless grep { $_ eq 'admin' } @{$query->{acls}};
 
-    my $tags = ['profile'];
-    my $posts = _post_helper($query, $tags, $query->{acls});
     my $css   = _build_themed_styles('config.css');
     my $js    = _build_themed_scripts('post.js');
-    push(@$css, '/styles/avatars.css');
 
     $query->{failure} //= -1;
 
@@ -300,14 +308,6 @@ sub config ($query, $input, $render_cb) {
         data_models        => _get_data_models(),
         current_theme      => $conf->param('general.theme') // '',
         current_data_model => $conf->param('general.data_model') // 'DUMMY',
-        post_visibilities  => [qw{public private unlisted}],
-        route       => '/about',
-        category    => '/about',
-        types       => ['profile'],
-        acls        => _post_helper({}, ['series'], $query->{acls}),
-        can_edit    => 1,
-        posts       => $posts,
-        edittype    => 'profile',
         message     => $query->{message},
         failure     => $query->{failure},
         to          => '/config',
@@ -404,12 +404,14 @@ sub post ($query, $input, $render_cb) {
         scripts     => $js,
         posts       => $posts,
         can_edit    => 1,
-        types       => [qw{microblog blog file series}],
+        types       => [qw{microblog blog file series profile}],
         route       => '/posts',
         category    => '/posts',
         page        => int($query->{page} || 1),
         limit       => int($query->{limit} || 1),
         sizes       => [25,50,100],
+        id          => $query->{id},
+        acls        => _post_helper({}, ['series'], $query->{acls}),
         edittype    => $query->{type} || 'microblog',
     });
 }

+ 0 - 9
www/templates/config.tx

@@ -27,15 +27,6 @@ If for example, you use mysql it will have to rely on either a local server, val
     <input type="submit" class="coolbutton" value="Commit Changes" />
 </form>
 <hr />
-
-<p class="title">
- User management:
-</p>
-Users and their sessions are stored in ~/.tcms/auth.db (sqlite3).  All other user data is considered a post like any other.
-<hr />
-: include "mbengine.tx";
-<hr />
-
 <p class="title">
  Theme cloner:
 </p>

+ 2 - 10
www/templates/mbengine.tx

@@ -1,17 +1,9 @@
 <div id="mbengine">
+    : if ( !$id ) {
     <div id="submissions">
-        <p id="subtitle" class="title">Submissions:</p>
-        <form id="posttype">
-            New post Type:
-            <select class="cooltext" name="type" onchange="this.form.submit()" >
-                : for $types -> $type {
-                    <option value="<: $type :>" <: if ($edittype == $type) { :>selected<: } :> ><: $type :></option>
-                : }
-            </select>
-            <hr />
-        </form>
         : include $edittype ~ ".tx";
     </div>
+    : }
     <div id="stories">
         : include "posts.tx";
     </div>

+ 9 - 2
www/templates/sysbar.tx

@@ -2,8 +2,15 @@
     <button title="Menu" id="clickme">☰</button>
     <span id="configbar">
         <a class="topbar" title="Back home" href="/">Home</a>
-        <a class="topbar" title="Edit Various Settings" href="/config">Settings</a>
-        <a class="topbar" title="Compose Posts" href="/post">Post</a>
+        <a href="/config"      title="Configuration" class="topbar">Settings</a>
+        <a href="/post/news"   title="Micro Blog"    class="topbar">News</a>
+        <a href="/post/blog"   title="Blog"          class="topbar">Blog</a>
+        <a href="/post/image"  title="Images"        class="topbar">Images</a>
+        <a href="/post/video"  title="Video"         class="topbar">Video</a>
+        <a href="/post/audio"  title="Audio"         class="topbar">Audio</a>
+        <a href="/post/files"  title="Files"         class="topbar">Files</a>
+        <a href="/post/series" title="Series"        class="topbar">Series</a>
+        <a href="/post/about"  title="About"         class="topbar">About</a>
     </span>
 </div>
 <div style="height:3rem;">hidon</div>