?

Log in

No account? Create an account
Tonks - Confused
Posted on Wednesday 23 March 2005 at 12:57 pm

Code fun!


# Comments  
    
      """
      <div class="clear"> </div>
      <div class="comments">""";

      ### start custom code ###
      
        # Set the basic order in which the links are supposed to appear, from left to right. Available links are:
        #   edit_entry       = edit the entry
        #   edit_tags        = edit the tags assigned to the entry
        #   mem_add          = add to your memories (of the user currently logged in)
        #   mem_as_comm      = add to memories of the community (the "authas"-link, can only be used by owner/moderators of community)
        #   watch_comments   = track/untrack the post
        #   tell_friend      = mail link to friend
        #   permalink        = link to the entry
        #   comments         = read/post comments link
        
        #   |                = all links before this symbol are printed aligned to the left, all others aligned to the right (standard)
        #                      to print all links aligned right (standard), set "|" first
        
        var string[] link_order = ["edit_entry", "|", "mem_add", "watch_comments", "comments"];
      
        # Set the urls to the images you want to use, or leave the quotes empty.
        # read/post comment links can not be set to images here (see Step 7)
        var string{} link_images = { "edit_entry"       => "IMAGE URL",
                                     "edit_tags"        => "IMAGE URL",
                                     "mem_add"          => "IMAGE URL",
                                     "mem_as_comm"      => "IMAGE URL",
                                     "tell_friend"      => "IMAGE URL",
                                     "watch_comments"   => "IMAGE URL",
                                     "unwatch_comments" => "IMAGE URL",
                                     "permalink"        => "IMAGE URL",
                                   };
        
        # Set the separator that should appear between the individual links or images
        # separator between read/post comment links can not be set here (see Step 6)
        var string link_separator = " | ";
        
        # Set the name of the community that the "mem_as_comm" link should work for
        var string community = "";
        
        
        
        # link texts (in case there is no image specified)
        var string{} link_text = { "edit_entry"       => $*text_edit_entry,
                                   "edit_tags"        => $*text_edit_tags,
                                   "mem_add"          => $*text_mem_add,
                                   "mem_as_comm"      => "+",
                                   "tell_friend"      => $*text_tell_friend,
                                   "watch_comments"   => $*text_watch_comments,
                                   "unwatch_comments" => $*text_unwatch_comments,
                                   "permalink"        => $*text_permalink,
                                 };
        
        # helper var to decide if separator is printed before link or not
        var bool i = false;
        
        # Step through the links in the order the user wants
        
        """<div class="leftlinks">""";
        foreach var string link ($link_order)
        {
          if ($link == "") { continue; } # skip emtpy quotes
          
          if ($link == "|") # close leftlinks div and open standard-aligned div
          {
            """</div><div>""";
            $i = false;
            continue;
          }
          
          # special case comment links
          if ($link == "comments")
          {
            if ($e.comments.enabled)
            {
              if ($i == true) { """$link_separator""";}
              $e.comments->print();
              $i = true;
            }
            else { " "; }
          }
          else
          {
            # get the url of the link
            var string url;
            if ($link == "permalink") { $url = $e.permalink_url; }
            else
            {
              var Link url_temp;
              $url_temp = ($link == "mem_as_comm") ? $e->get_link("mem_add") : $e->get_link($link);
              
              if (isnull $url_temp)
              {
                if ($link == "watch_comments")
                {
                  $url_temp = $e->get_link("unwatch_comments");
                  $link = "unwatch_comments";
                }
                else { continue; }
              }
              $url = $url_temp.url;
              if ($link == "mem_as_comm") { $url = """$url?authas=$community"""; }
            }
            
            # get the link image or text
            var string text;
            if (clean_url($link_images{$link}) == "") { $text = $link_text{$link}; }
            else { $text = """<img src="$link_images{$link}">"""; }
            
            # print separator, link and text/image
            if ($i == true) { """$link_separator""";}
            """<a href="$url" title="$link_text{$link}">$text</a>""";

            $i = true;
          }
        }
        
      "</div>";

      ### end custom code ###

      """
      </div>

    </div>
  </div>

  <div class="separator"></div>
  <div class="clear"> </div>""";
}

Comments:

Rachael
bratty_jedi at 5:19 pm on 23 March 2007 (UTC) (Link)

.leftlinks {
  float: left;
  position: relative;
  }
Rachael
bratty_jedi at 5:27 pm on 23 March 2007 (UTC) (Link)
#Force comments to indent from left, no matter userpic position
function EntryPage::print_comments( Comment[] comments )
{
    if ( size $comments == 0 )
    {
        return;
    }

    foreach var Comment c ( $comments )
    {
        var int indent = ($c.depth - 1) * 20;
        var string partialcomment = $c.full         ? "" : "partial";

        """<a name="$c.anchor"></a>""";
        """<div class="commentbox$partialcomment" id="$c.dom_id" style="margin-left: ${indent}px">\n""";
        if ( $c.full )
        {
            $this->print_comment( $c );
        }
        else
        {
            $this->print_comment_partial( $c );
           }
        "</div>";
        $this->print_comments( $c.replies );
	}
}
Rachael
bratty_jedi at 4:17 pm on 27 March 2007 (UTC) (Link)

#Link Current View
function Page::lay_print_header()
"Prints header"
{
    var Page page = get_page();
    var string title = $this->title();

    print  """
    <div id="header">
    <ul class="navheader">""";
            var string website_name = $.journal.website_name ? $.journal.website_name : $*text_website_default_name;
                if ($.journal.website_url != "")
                {
                    println safe """<li><a href="$.journal.website_url">$website_name</a></li>""";
                }

                foreach var string v ($.views_order) {
                    if ($.view == $v) {
                         "<li class=\"view\"><a href=\""+$.view_url{$v}+"\">"+lang_viewname($v)+"</a></li>";
                            } else {
                            println "<li><a href=\""+$.view_url{$v}+"\">"+lang_viewname($v)+"</a></li>";
                            }
                }
        print safe """
        </ul>
        <div class="title">
            $title
        </div>
        <div class="subtitle">
            $.global_subtitle
        </div>
    </div>
""";
}


   Leave a New Comment
Previous Entry  Next Entry