GureWork > espacios de Coworking topalekuak :)
Template:TemplateSourceViewer >

Template:TemplateSourceViewer
Template:TemplateSourceViewerEdit

    Tabla de contenidos
    No hay encabezados
    //@himikel #ver 2010-03-12: some modificactions to allow use of templates in other path out the standard template scope
    //@himikel #par 2010-03-12: 'path' where templates are located
    //@himikel #mod 2010-12-27: adapt to use templates in subpages & correct current page treatment
    
    if (error is not nil)
        <span style="color:red"> error </span>;
    if (!install) {
        if (tpage is nil) <p>
            "This page allows you to view quickly and easily the DekiScript blocks of a template with syntax highlighting, ";
            "which is very useful for debugging. ";
            "You can also access the template HTML source for easy installation; just click the \"(view template installation instructions)\" link.";
        </p>;
        //@himikel #mod 2010-12-27: adapt to use templates in subpages & correct current page treatment    
        var template_list = [ (p.path ? string.substr(p.path, (inscope ? #searchpre : string.indexof(p.path,tpath)+string.length(tpath))) : nil)
        //var template_list = [ string.substr(p.path, (inscope ? #searchpre : string.lastindexof(p.path,"/")+1))
            foreach var p in wiki.getsearch(searchloc, 999) where string.startswith(p.path..'',searchpre) ]; //#mod 2010-03-12 @himikel
        <p>
            "Select template: ";
            <select ctor="when($this.change) window.location.href={{page.uri}}+'&templatename='+escape($this.attr('value'))+{{(!inscope ? '&path='..tpath : '')}};">
                if (tpage is nil || !list.contains(template_list, tpage))
                    <option selected="selected" value=""> "(none selected)" </option>;
                foreach (var t in list.sort(template_list))
                    //@himikel #mod 2010-12-27: adapt to use templates in subpages & correct current page treatment    var template_list = [ (p.path ? string.substr(p.path, (inscope ? #searchpre : string.indexof(p.path,tpath)+string.length(tpath))) : nil)
                    if (t!=nil)
                        <option selected=(t==tpage.name ? "selected" : nil)> t </option>;
            </select>;
        </p>;
        if (tpage is not nil) {
            <p><a href=(page.uri & { templatename: tpage.name, install:true } & (!inscope ? { path : tpath } : {}))> "(view template installation instructions)" </a></p>; //#mod 2010-03-12 @himikel
            if (xml.text(tpage.xml, ".//pre[@class='script']")) {
                <h2> "DekiScript source for "; web.link(tpage.uri & { action:"source" }, tpage.title); </h2>;
                <p> "Each block of style 'DekiScript' is shown (there may be additional content in the template source)" </p>;
                foreach (var x in xml.select(tpage.xml, ".//pre[@class='script']"))
                    syntax.dekiscript(xml.text(x));
            }
            else <p style="font-weight:bold">
                web.link(tpage.uri & { action:"source" }, tpage.title);; " has no DekiScript blocks";
            </p>;
        }    
    }
    	if (install && !embedded) {
        <p><a href=(page.uri & { templatename: tpage.name })> "(switch to DekiScript source view)" </a></p>;
        <p style="font-size:1.1em; font-weight:bold"> "Installation Instructions" </p>;
    }

    These instructions will help you install the template{{ if (multiple) "s"; " "; namelist }} on your wiki quickly and correctly. {{ if (!embedded) { "There might be additional installation requirements; be sure to see the template documentation for details. "; <em>"Note that this procedure is designed for single-page templates only." </em>; } }}

    Perform the following steps{{ if (multiple) { <em> " for each template" </em> } }}:

    1. Copy the template source code:
      1. If the code in the "HTML Source" area below is not already visible and selected, click the "View" button to display and select it.
      2. Copy it to your clipboard (CTRL-C).
    2. Create a new template on your wiki:
      1. Select the Tools->Templates menu item on your wiki
      2. Click "New Page" button.  This will open the editor on a new page titled (for the moment) "Template:Page Title".
    3. Paste in the source code:
      1. In the editor, click the "Source" button to view the HTML source of the page.
      2. Select all text (CTRL-A)
      3. Paste in the template source code from the clipboard (CTRL-V).
    4. Click "Save" button.
    		foreach (var t in tlist) {
        var myId = @id .. "_" .. t.id;
        var ct = "when($this.click) { $(\'#" ..myId .."\').toggle(); if($(\'#" ..myId .."\').is(':visible')){$(\'#" ..myId .."\').select(); $this.val('Hide');}else{$this.val('View');}}"; 
        <p style="font-size:1.1em; font-weight:bold">
            <input type="button" value="View" ctor=(ct)/>;
            "HTML Source for "; web.link(t.uri & { action:"source" }, t.title);
        </p>;    
        var source = [ "<h1>" .. t.title .. "</h1>" ] ..
            list.splice(string.split(string.substr(xml.format(xml.select(t.xml,".//body")),0,-7),"\n"), 0,1);
        <textarea class="toggleme" id=(myId) style="max-width:100%; overflow-x:auto" wrap="off"
            rows=(#source) cols=(num.int(1.5*list.max([ #s foreach var s in source]))) readonly="readonly">
            foreach (var s in source)
                (__index ? "\n" : "") .. s;
        </textarea>;
    }
    
    		<html><head>
        <style type="text/css"> ".toggleme {display:none;}" </style>
    </head></html>
    
    Powered by MindTouch Core (Expired)