소스 검색

Probably a fix to #157

George S. Baugh 5 년 전
부모
커밋
04fe2db071
5개의 변경된 파일65개의 추가작업 그리고 55개의 파일을 삭제
  1. 3 0
      lib/Trog/Routes/HTML.pm
  2. 1 0
      www/server.psgi
  3. 5 1
      www/templates/config.tx
  4. 2 54
      www/templates/header.tx
  5. 54 0
      www/templates/meta.tx

+ 3 - 0
lib/Trog/Routes/HTML.pm

@@ -283,6 +283,7 @@ sub index ($query,$render_cb, $content = '', $i_styles = []) {
         default_tags   => $default_tags,
         meta_desc      => $meta_desc,
         fb_app_id      => $fb_app_id,
+        indexable      => 1,
     });
 }
 
@@ -461,6 +462,7 @@ sub config ($query, $render_cb) {
         data_models        => _get_data_models(),
         current_theme      => $conf->param('general.theme') // '',
         current_data_model => $conf->param('general.data_model') // 'DUMMY',
+        fb_app_id          => $conf->param('general.fb_app_id') // '',
         message     => $query->{message},
         failure     => $query->{failure},
         to          => '/config',
@@ -492,6 +494,7 @@ Implements /config/save route.  Saves what little configuration we actually use
 sub config_save ($query, $render_cb) {
     $conf->param( 'general.theme',      $query->{theme} )      if defined $query->{theme};
     $conf->param( 'general.data_model', $query->{data_model} ) if $query->{data_model};
+    $conf->param( 'general.fb_app_id', $query->{fb_app_id} ) if $query->{fb_app_id};
 
     $query->{failure} = 1;
     $query->{message} = "Failed to save configuration!";

+ 1 - 0
www/server.psgi

@@ -205,6 +205,7 @@ sub _render ($template, $vars, @headers) {
             },
             strip_and_trunc => sub {
                 my $s = shift;
+                return unless $s;
                 $s =~ s/<[^>]*>//g;
                 return substr $s, 0, 280;
             },

+ 5 - 1
www/templates/config.tx

@@ -4,7 +4,7 @@
  General settings:
 </p>
 This controls your Theme and Data Model used.
-The Data Model *must* be 0-configuration.
+The Data Model <em>must</em> be 0-configuration.
 If for example, you use mysql it will have to rely on either a local server, valid config file or connection proxy/pooler locally.
 <hr />
 <form class="Submissions Config" id="mainConfig" method="post" action="/config/save">
@@ -23,6 +23,10 @@ If for example, you use mysql it will have to rely on either a local server, val
         : }
     </select>
     </div>
+    <div>
+    <span>Facebook App ID:</span>
+    <input type="text" class="cooltext" name="fb_app_id" value="<: $fb_app_id :>" />
+    </div>
     <br />
     <input type="submit" class="coolbutton" value="Commit Changes" />
 </form>

+ 2 - 54
www/templates/header.tx

@@ -4,62 +4,10 @@
         <title><: $title :></title>
         <meta charset="utf-8" />
         <link rel="icon" type="image/vnd.microsoft.icon" href="<: $theme_dir :>/img/icon/favicon.ico" />
-        <meta name="description" content="<: $meta_desc | strip_and_trunc :>"/>
-        : if ($default_tags) {
-        <meta name="tags" content="<: $default_tags :>" />
-        : }
-
-        <meta property="postid" content="<: $primary_post.id :>" />
-
-        <!-- Open Graph / Facebook -->
-        <meta property="og:type" content="<: $og_type :>" />
-        <meta property="og:url" content="https://<: $domain :>/<: $route :>" />
-        <meta property="og:title" content="<: $title :>" />
-        : if ($default_tags) {
-        <meta property="og:article:tags" content="<: $default_tags :>" />
-        : }
-        : if ($primary_post.is_image) {
-        <meta property="og:image" content="https://<: $domain :>/<: $primary_post.href :>" />
-        <meta property="og:image:type" content="<: $primary_post.content_type :>" />
-        <meta property="og:image:width" content="1280" />
-        <meta property="og:image:height" content=720 />
-        : }
-        : elsif ($primary_post.is_video) {
-        <meta property="og:video" content="https://<: $domain :>/<: $primary_post.href :>" />
-        <meta property="og:video:type"  content="<: $primary_post.content_type :>" />
-        <meta property="og:video:width" content="1280" />
-        <meta property="og:video:height" content="720" />
-        <meta property="og:video:image"  content="https://<: $domain :>/<: $primary_post.preview :>" />
-        : }
-        : if ($primary_post.user) {
-        <meta property="og:article:author" content="<: $primary_post.user :>" />
-        : }
-        : if ($primary_post.created) {
-        <meta property="og:article:published_time" content="<: $primary_post.created | iso8601 :>" />
-        <meta property="og:article:modified_time" content="<: $primary_post.created | iso8601 :>" />
-        : }
-        : if ($fb_app_id) {
-        <meta property="fb:app_id" content="<: $fb_app_id :>" />
-        : }
 
-        <!-- Twitter -->
-        <meta property="twitter:card" content="<: $twitter_type :>" />
-        <meta property="twitter:url" content="https://<: $domain :>/<: $route :>" />
-        : if ($primary_post.is_image) {
-        <meta property="twitter:image" content="https://<: $domain :>/<: $primary_post.href :>" />
-        <meta property="twitter:image:type" content="<: $primary_post.type :>" />
-        <meta property="twitter:image:width" content="1280" />
-        <meta property="twitter:image:height" content=720 />
-        : }
-        : elsif ($primary_post.is_video) {
-        <meta property="twitter:player:stream" content="https://<: $domain :>/<: $primary_post.href :>" />
-        <meta property="twitter:player:stream:content_type"  content="<: $primary_post.type :>" />
-        <meta property="twitter:player:width" content="1280" />
-        <meta property="twitter:player:height" content="720" />
-        <meta property="twitter:player" content="https://<: $domain :>/<: $route :>?embed=1" />
+        : if ($indexable) {
+        : include "meta.tx";
         : }
-        <meta property="twitter:title" content="<: $title :>" />
-        <meta property="twitter:description" content="<: $meta_desc | strip_and_trunc :>" />
 
         <meta name="viewport" content="width=device-width">
         <link rel="stylesheet" type="text/css" href="/styles/structure.css" />

+ 54 - 0
www/templates/meta.tx

@@ -0,0 +1,54 @@
+<meta name="description" content="<: $meta_desc | strip_and_trunc :>"/>
+: if ($default_tags) {
+<meta name="tags" content="<: $default_tags :>" />
+: }
+
+<!-- Open Graph / Facebook -->
+<meta property="og:type" content="<: $og_type :>" />
+<meta property="og:url" content="https://<: $domain :>/<: $route :>" />
+<meta property="og:title" content="<: $title :>" />
+: if ($default_tags) {
+<meta property="og:article:tags" content="<: $default_tags :>" />
+: }
+: if ($primary_post.is_image) {
+<meta property="og:image" content="https://<: $domain :>/<: $primary_post.href :>" />
+<meta property="og:image:type" content="<: $primary_post.content_type :>" />
+<meta property="og:image:width" content="1280" />
+<meta property="og:image:height" content=720 />
+: }
+: elsif ($primary_post.is_video) {
+<meta property="og:video" content="https://<: $domain :>/<: $primary_post.href :>" />
+<meta property="og:video:type"  content="<: $primary_post.content_type :>" />
+<meta property="og:video:width" content="1280" />
+<meta property="og:video:height" content="720" />
+<meta property="og:video:image"  content="https://<: $domain :>/<: $primary_post.preview :>" />
+: }
+: if ($primary_post.user) {
+<meta property="og:article:author" content="<: $primary_post.user :>" />
+: }
+: if ($primary_post.created) {
+<meta property="og:article:published_time" content="<: $primary_post.created | iso8601 :>" />
+<meta property="og:article:modified_time" content="<: $primary_post.created | iso8601 :>" />
+: }
+: if ($fb_app_id) {
+<meta property="fb:app_id" content="<: $fb_app_id :>" />
+: }
+
+<!-- Twitter -->
+<meta property="twitter:card" content="<: $twitter_type :>" />
+<meta property="twitter:url" content="https://<: $domain :>/<: $route :>" />
+: if ($primary_post.is_image) {
+<meta property="twitter:image" content="https://<: $domain :>/<: $primary_post.href :>" />
+<meta property="twitter:image:type" content="<: $primary_post.type :>" />
+<meta property="twitter:image:width" content="1280" />
+<meta property="twitter:image:height" content=720 />
+: }
+: elsif ($primary_post.is_video) {
+<meta property="twitter:player:stream" content="https://<: $domain :>/<: $primary_post.href :>" />
+<meta property="twitter:player:stream:content_type"  content="<: $primary_post.type :>" />
+<meta property="twitter:player:width" content="1280" />
+<meta property="twitter:player:height" content="720" />
+<meta property="twitter:player" content="https://<: $domain :>/<: $route :>?embed=1" />
+: }
+<meta property="twitter:title" content="<: $title :>" />
+<meta property="twitter:description" content="<: $meta_desc | strip_and_trunc :>" />