Максим Червонный (fiskus_boulder) wrote in changelog,
Максим Червонный
fiskus_boulder
changelog

[ljcom] r11048: LJSUP-9934: Refactoring of print_comment...

Committer: mchervonniy
LJSUP-9934: Refactoring of print_comment_partial() function in s2 style
U   trunk/bin/upgrading/s2layers/anovelconundrum/layout.s2
U   trunk/bin/upgrading/s2layers/gradient/layout.s2
Modified: trunk/bin/upgrading/s2layers/anovelconundrum/layout.s2
===================================================================
--- trunk/bin/upgrading/s2layers/anovelconundrum/layout.s2	2011-09-28 09:21:37 UTC (rev 11047)
+++ trunk/bin/upgrading/s2layers/anovelconundrum/layout.s2	2011-09-28 09:56:50 UTC (rev 11048)
@@ -145,6 +145,8 @@
     property use text_read_all_spam_comments;
     property use text_view_games;
     property use text_share;
+
+   set text_nosubject = "a reply";
 }
 
 propgroup customcss {
@@ -1202,13 +1204,15 @@
 
 function EntryPage::print_comment_partial (Comment c) {
     var string poster = defined $c.poster ? $c.poster->as_string() : """<em class="noposter">$*text_poster_anonymous</em>""";
+    var string subj = $c.subject != "" ? "&ldquo;" + $c.subject + "&rdquo;" : """<em class="nosubject">$*text_nosubject</em>""";
     var string sep = "&middot;";
-    var bool subj = $c.subject != "";
+    var string subj_sep = $c.subject != "" ? "replied, " : "posted ";
+
     print safe "<div class='ult' style='width:$*body_width; margin-top:${*font_leading}pt;'>";
     "&mdash;&thinsp;On " + $c->time_display("long", "") + ", $poster ";
     if ($c.metadata{"poster_ip"}) { "(" + $c.metadata{"poster_ip"} + ") "; }
-    if($subj) { """replied, <a href="$c.permalink_url">&ldquo;$c.subject&rdquo;</a>"""; }
-    else { """posted <a href="$c.permalink_url">a reply</a>"""; }
+    """$subj_sep <a href="$c.permalink_url">$subj</a>""";
+
     $c->print_expand_collapse_links({ "expand"=>" $sep %_", "collapse"=>" $sep %_"});
     "</div>";
 }

Modified: trunk/bin/upgrading/s2layers/gradient/layout.s2
===================================================================
--- trunk/bin/upgrading/s2layers/gradient/layout.s2	2011-09-28 09:21:37 UTC (rev 11047)
+++ trunk/bin/upgrading/s2layers/gradient/layout.s2	2011-09-28 09:56:50 UTC (rev 11048)
@@ -1671,69 +1671,61 @@
 }
 
 function EntryPage::print_comment (Comment c) {
-   var string indent = ($c.depth - 1) * 15 + "px";
-
-   """<a name="$c.anchor"></a><div id="$c.dom_id" class="comment" style="margin-left: $indent;">""";
-   $this->lay_commentmeta($c);
-   $c->print_text();
-   """
-   <div class="commentlinks">$*comment_link_divider """;
-      if ($c.thread_url != "") {
-         """<a href="$c.thread_url">Thread</a> $*comment_link_divider """;
-         var Link expand_link = $c->get_link("expand_comments");
-         if (defined $expand_link) {
-            println $c->expand_link() + " $*comment_link_divider";
-         }
-      }
-      if ($c.parent_url != "") {
-         """<a href="$c.parent_url">Parent</a> $*comment_link_divider """;
-      }
-      if (not $c.frozen) {
-         $c->print_reply_link({"linktext" => $*text_comment_reply});
-      }
-   """</div>""";
-      $c->print_reply_container();
-   """</div>""";
-   $this->print_comments($c.replies);
+    var Page p = get_page();
+    var string indent = ($c.depth - 1) * 15 + "px";
+    """<a name="$c.anchor"></a>
+    <div id="$c.dom_id" class="comment" style="margin-left: $indent;">""";
+    if (($c.spam) and (not $p.showspam) and (not $c.can_marked_as_spam) and (size($c.replies) > 0)) {
+        """<strong>$*text_spam_comment</strong>""";
+    } elseif ($c.screened) {
+        """$*text_comment_screened""";
+    } elseif ($c.deleted) {
+        """$*text_comment_deleted""";
+    } elseif ($c.full) {
+        $this->print_comment_full($c);
+    } else {
+        $this->print_comment_partial($c);
+    }
+    """</div>""";
 }
 
-function EntryPage::print_comment_partial (Comment c) {
-    if($c.depth == 1) {
-        var Comment[] replies;
-        $replies = $c.replies;
-        var int count = 0;
-        foreach var Comment reply ($replies) {
-            $count ++;
+function EntryPage::print_comment_full (Comment c) {
+    $this->lay_commentmeta($c);
+    $c->print_text();
+    """<div class="commentlinks">$*comment_link_divider """;
+    if ($c.thread_url != "") {
+        """<a href="$c.thread_url">Thread</a> $*comment_link_divider """;
+        var Link expand_link = $c->get_link("expand_comments");
+        if (defined $expand_link) {
+            println $c->expand_link() + " $*comment_link_divider";
         }
     }
-    var string indent = ($c.depth - 1) * 15 + "px";
-    """<div class="comment" id="$c.dom_id" style="margin-left: $indent;">""";
-    if($c.screened) {
-        """Screened Comment""";
-    } elseif ($c.deleted) {
-        """Deleted Comment""";
-    } else {
-        var string poster = defined $c.poster ? "<a href=\"" + $c.poster->base_url() + "\">$c.poster.username</a>" : """<em class="noposter">$*text_poster_anonymous</em>""";
-        var string subj = $c.subject != "" ? $c.subject : """<em class="nosubject">$*text_nosubject</em>""";
-        var string sep = "by";
-        print safe """<a href="$c.permalink_url">$subj</a> $sep $poster """;
-        $c->print_expand_collapse_links({ "expand"=>" $sep %_", "collapse"=>" $sep %_"});
+    if ($c.parent_url != "") {
+        """<a href="$c.parent_url">Parent</a> $*comment_link_divider """;
     }
+    if (not $c.frozen) {
+        $c->print_reply_link({"linktext" => $*text_comment_reply});
+    }
+    $c->print_expand_collapse_links({ "expand"=>" $*comment_link_divider %_", "collapse"=>" $*comment_link_divider %_"});
     """</div>""";
-    $this->print_comments($c.replies);
+    $c->print_reply_container();
 }
 
+function EntryPage::print_comment_partial (Comment c) {
+    #var string poster = defined $c.poster ? "<a href=\"" + $c.poster->base_url() + "\">$c.poster.username</a>" : """<em class="noposter">$*text_poster_anonymous</em>""";
+    var string poster = defined $c.poster ? $c.poster->as_string() : """<em class="noposter">$*text_poster_anonymous</em>""";
+    var string subj = $c.subject != "" ? $c.subject : """<em class="nosubject">$*text_nosubject</em>""";
+    var string subj_sep = "by";
+    var string sep = "::";
+    print safe """<a href="$c.permalink_url">$subj</a> $subj_sep $poster """;
+    $c->print_expand_collapse_links({ "expand"=>" $sep %_", "collapse"=>" $sep %_"});
+}
+
 function EntryPage::print_comments (Comment[] cs) {
-    var Page p = get_page();
+    if (size $cs == 0) { return; }
     foreach var Comment c ($cs) {
-        if (($c.spam) and (not $p.showspam) and (not $c.can_marked_as_spam) and (size($c.replies) > 0)) {
-            var string indent = ($c.depth - 1) * 15 + "px";
-            """<div id="$c.dom_id" class="comment" style="margin-left: $indent;"><strong>$*text_spam_comment</strong></div>""";
-        } elseif ($c.full) {
-            $this->print_comment($c);
-        } else {
-            $this->print_comment_partial($c);
-        }
+        $this->print_comment($c);
+        $this->print_comments($c.replies);
     }
 }
 

Tags: fiskus_boulder, ljcom, s2
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments