fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-05-02 01:14 pm

[dw-free] Allow customized Reading Page subtitles

[commit: http://hg.dwscoalition.org/dw-free/rev/4cf824f91dc2]

http://bugs.dwscoalition.org/show_bug.cgi?id=3277

Add an option for a subtitle for the Reading Page, load/use it where
appropriate (First patch!)

Patch by [personal profile] metawidget.

Files modified:
  • bin/upgrading/en.dat
  • bin/upgrading/proplists.dat
  • bin/upgrading/s2layers/core2.s2
  • cgi-bin/LJ/S2/FriendsPage.pm
  • cgi-bin/LJ/Widget/JournalTitles.pm
  • cgi-bin/ljlib.pl
  • htdocs/stc/widgets/journaltitles.css
--------------------------------------------------------------------------------
diff -r 034efde6e7ca -r 4cf824f91dc2 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Mon May 02 19:54:51 2011 +0800
+++ b/bin/upgrading/en.dat	Mon May 02 21:13:34 2011 +0800
@@ -4537,6 +4537,8 @@ widget.journaltitles.desc=These titles a
 
 widget.journaltitles.edit=Edit
 
+widget.journaltitles.friendspagesubtitle=Reading Page Subtitle:
+
 widget.journaltitles.friendspagetitle=Reading Page Title:
 
 widget.journaltitles.journalsubtitle=Journal Subtitle:
diff -r 034efde6e7ca -r 4cf824f91dc2 bin/upgrading/proplists.dat
--- a/bin/upgrading/proplists.dat	Mon May 02 19:54:51 2011 +0800
+++ b/bin/upgrading/proplists.dat	Mon May 02 21:13:34 2011 +0800
@@ -333,6 +333,14 @@ userproplist.friendspagetitle:
   indexed: 0
   multihomed: 0
   prettyname: Friends Page Title
+
+userproplist.friendspagesubtitle:
+  cldversion: 4
+  datatype: char
+  des: Subtitle of Friends Page
+  indexed: 0
+  multihomed: 0
+  prettyname: Friends Page Subtitle
 
 userproplist.gender:
   cldversion: 4
diff -r 034efde6e7ca -r 4cf824f91dc2 bin/upgrading/s2layers/core2.s2
--- a/bin/upgrading/s2layers/core2.s2	Mon May 02 19:54:51 2011 +0800
+++ b/bin/upgrading/s2layers/core2.s2	Mon May 02 21:13:34 2011 +0800
@@ -734,6 +734,9 @@ class FriendsPage extends RecentPage
     var readonly string friends_title
     "A user-selected title for their friends page.";
 
+    var readonly string friends_subtitle
+    "A user-selected subtitle for their friends page.";
+
     var string friends_mode
     "The 'mode' of this view. An empty string indicates a normal friends view, while 'network' indicates the network view.";
 }
@@ -3598,6 +3601,14 @@ function FriendsPage::print_global_title
 }
 function Page::print_global_subtitle() {
     if ($.global_subtitle) {
+        """<h2 id="subtitle"><span>""" + $.global_subtitle + """</span></h2>""";
+    }
+}
+function FriendsPage::print_global_subtitle(){
+    if ($.friends_subtitle){
+        """<h2 id="subtitle"><span>""" + $.friends_subtitle + """</span></h2>""";
+    } elseif ($.friends_title) {
+    } else {
         """<h2 id="subtitle"><span>""" + $.global_subtitle + """</span></h2>""";
     }
 }
diff -r 034efde6e7ca -r 4cf824f91dc2 cgi-bin/LJ/S2/FriendsPage.pm
--- a/cgi-bin/LJ/S2/FriendsPage.pm	Mon May 02 19:54:51 2011 +0800
+++ b/cgi-bin/LJ/S2/FriendsPage.pm	Mon May 02 21:13:34 2011 +0800
@@ -32,6 +32,7 @@ sub FriendsPage
     $p->{'entries'} = [];
     $p->{'friends'} = {};
     $p->{'friends_title'} = LJ::ehtml($u->{'friendspagetitle'});
+    $p->{'friends_subtitle'} = LJ::ehtml($u->{'friendspagesubtitle'});
 
     # Add a friends-specific XRDS reference
     $p->{'head_content'} .= qq{<meta http-equiv="X-XRDS-Location" content="}.LJ::ehtml($u->journal_base).qq{/data/yadis/friends" />\n};
diff -r 034efde6e7ca -r 4cf824f91dc2 cgi-bin/LJ/Widget/JournalTitles.pm
--- a/cgi-bin/LJ/Widget/JournalTitles.pm	Mon May 02 19:54:51 2011 +0800
+++ b/cgi-bin/LJ/Widget/JournalTitles.pm	Mon May 02 21:13:34 2011 +0800
@@ -37,7 +37,7 @@ sub render_body {
     $ret .= "<div class='theme-titles-content'>";
     $ret .= "<p class='detail'>" . $class->ml('widget.journaltitles.desc') . " " . LJ::help_icon('journal_titles') . "</p>";
 
-    foreach my $id (qw( journaltitle journalsubtitle friendspagetitle )) {
+    foreach my $id (qw( journaltitle journalsubtitle friendspagetitle friendspagesubtitle )) {
         my $eprop = LJ::ehtml( $u->prop( $id ) ) || '';
         $ret .= $class->start_form( id => "${id}_form" );
 
@@ -97,32 +97,40 @@ sub js {
             self.journaltitle_value = $("journaltitle").value;
             self.journalsubtitle_value = $("journalsubtitle").value;
             self.friendspagetitle_value = $("friendspagetitle").value;
+            self.friendspagesubtitle_value = $("friendspagesubtitle").value;
 
             // show view mode
             $("journaltitle_view").style.display = "inline";
             $("journalsubtitle_view").style.display = "inline";
             $("friendspagetitle_view").style.display = "inline";
+            $("friendspagesubtitle_view").style.display = "inline";
             $("journaltitle_cancel").style.display = "inline";
             $("journalsubtitle_cancel").style.display = "inline";
             $("friendspagetitle_cancel").style.display = "inline";
+            $("friendspagesubtitle_cancel").style.display = "inline";
             $("journaltitle_modify").style.display = "none";
             $("journalsubtitle_modify").style.display = "none";
             $("friendspagetitle_modify").style.display = "none";
+            $("friendspagesubtitle_modify").style.display = "none";
 
             // set up edit links
             DOM.addEventListener($("journaltitle_edit"), "click", function (evt) { self.editTitle(evt, "journaltitle") });
             DOM.addEventListener($("journalsubtitle_edit"), "click", function (evt) { self.editTitle(evt, "journalsubtitle") });
             DOM.addEventListener($("friendspagetitle_edit"), "click", function (evt) { self.editTitle(evt, "friendspagetitle") });
+            DOM.addEventListener($("friendspagesubtitle_edit"), "click", function (evt) { self.editTitle(evt, "friendspagesubtitle") });
 
             // set up cancel links
             DOM.addEventListener($("journaltitle_cancel"), "click", function (evt) { self.cancelTitle(evt, "journaltitle") });
             DOM.addEventListener($("journalsubtitle_cancel"), "click", function (evt) { self.cancelTitle(evt, "journalsubtitle") });
             DOM.addEventListener($("friendspagetitle_cancel"), "click", function (evt) { self.cancelTitle(evt, "friendspagetitle") });
+            DOM.addEventListener($("friendspagesubtitle_cancel"), "click", function (evt) { self.cancelTitle(evt, "friendspagesubtitle") });
 
             // set up save forms
             DOM.addEventListener($("journaltitle_form"), "submit", function (evt) { self.saveTitle(evt, "journaltitle") });
             DOM.addEventListener($("journalsubtitle_form"), "submit", function (evt) { self.saveTitle(evt, "journalsubtitle") });
             DOM.addEventListener($("friendspagetitle_form"), "submit", function (evt) { self.saveTitle(evt, "friendspagetitle") });
+            DOM.addEventListener($("friendspagesubtitle_form"), "submit", function (evt) { self.saveTitle(evt, "friendspagesubtitle") });
+
         },
         editTitle: function (evt, id) {
             $(id + "_modify").style.display = "inline";
@@ -133,13 +141,21 @@ sub js {
             if (id == "journaltitle") {
                 this.cancelTitle(evt, "journalsubtitle");
                 this.cancelTitle(evt, "friendspagetitle");
+                this.cancelTitle(evt, "friendspagesubtitle");
             } else if (id == "journalsubtitle") {
                 this.cancelTitle(evt, "journaltitle");
                 this.cancelTitle(evt, "friendspagetitle");
+                this.cancelTitle(evt, "friendspagesubtitle");
             } else if (id == "friendspagetitle") {
                 this.cancelTitle(evt, "journaltitle");
                 this.cancelTitle(evt, "journalsubtitle");
+                this.cancelTitle(evt, "friendspagesubtitle");
+            } else if (id == "friendspagesubtitle") {
+                this.cancelTitle(evt, "journaltitle");
+                this.cancelTitle(evt, "journalsubtitle");
+                this.cancelTitle(evt, "friendspagetitle");
             }
+
 
             Event.stop(evt);
         },
@@ -154,7 +170,9 @@ sub js {
                 $("journalsubtitle").value = this.journalsubtitle_value;
             } else if (id == "friendspagetitle") {
                 $("friendspagetitle").value = this.friendspagetitle_value;
-            }
+            } else if (id == "friendspagesubtitle") {
+                $("friendspagesubtitle").value = this.friendspagesubtitle_value;
+            } 
 
             Event.stop(evt);
         },
diff -r 034efde6e7ca -r 4cf824f91dc2 cgi-bin/ljlib.pl
--- a/cgi-bin/ljlib.pl	Mon May 02 19:54:51 2011 +0800
+++ b/cgi-bin/ljlib.pl	Mon May 02 21:13:34 2011 +0800
@@ -171,7 +171,7 @@ LJ::MemCache::init();
                  },
                  "read" => {
                      "des" => "Reading Page",
-                     "owner_props" => ["opt_usesharedpic", "friendspagetitle"],
+                     "owner_props" => ["opt_usesharedpic", "friendspagetitle", "friendspagesubtitle"],
                  },
                  "network" => {
                      "des" => "Network View",
diff -r 034efde6e7ca -r 4cf824f91dc2 htdocs/stc/widgets/journaltitles.css
--- a/htdocs/stc/widgets/journaltitles.css	Mon May 02 19:54:51 2011 +0800
+++ b/htdocs/stc/widgets/journaltitles.css	Mon May 02 21:13:34 2011 +0800
@@ -2,7 +2,7 @@
     line-height: 22px;
 }
 .theme-titles label {
-    width: 10.5em;
+    width: 12em;
     float: left;
     line-height: 22px;
 }
--------------------------------------------------------------------------------
ninetydegrees: Art: self-portrait (Default)

[personal profile] ninetydegrees 2011-05-02 05:25 pm (UTC)(link)
function FriendsPage::print_global_subtitle(){
    if ($.friends_subtitle){
        """<h2 id="subtitle"><span>""" + $.friends_subtitle + """</span></h2>""";
    } elseif ($.friends_title) {
    } else {
        """<h2 id="subtitle"><span>""" + $.global_subtitle + """</span></h2>""";
    }
}


is a bit strange. It seems } elseif ($.friends_title) { is extra code that got there by mistake.
Edited (bad HTML! bad!) 2011-05-02 17:26 (UTC)
kareila: (Default)

[personal profile] kareila 2011-05-02 05:32 pm (UTC)(link)
It looks to me like the effect of that would be to not print $.global_subtitle if $.friends_title is set. That may very well be what the author intended and sounds like a reasonable thing to do. I do agree that this way of expressing it is a bit odd, but I don't think it's a mistake.
ninetydegrees: Art: self-portrait (Default)

[personal profile] ninetydegrees 2011-05-02 05:38 pm (UTC)(link)
Oh I see. Hmm this is not how things work for the title so I find this a bit weird. It also means that people who don't want to have a specific subtitle on their reading page will have to enter their journal subtitle twice.

Edit: to clarify I understand the reasoning (if you have a reading title, let's assume you want a specific subtitle too) but, well, hmm. :)
Edited 2011-05-02 17:42 (UTC)