GureWiki > Ezagutza partekatzen / Compartiendo conocimiento
GureWiki: "Ezagutza partekatzen / Compartiendo conocimiento"
Template:@himikel > PageHeader
    Aurkibidea
    Goibururik ez

    This template shows the page header with its description, table of contents (TOC) and navigation tree

    Paramters: Page, Description, Theme, IncludeToc (=true)

    var mPars = {     
      mPage: (__request.args.page ? string.deserialize(__request.args.page) : null ) ?? args.page ?? page,
      smDesc: ((__request.args.desc) ? ((__request.args.desc is map) ? __request.args.desc : { __ : __request.args.desc }) : null) ??
              ((args.desc) ? ((args.desc is map) ? args.desc : { __ : args.desc }) : null) ?? null,
      slLang: ((__request.args.lang) ? ((__request.args.lang is list) ? __request.args.lang : [__request.args.lang]) : null) ??
              ((args.lang) ? ((args.lang is list) ? args.lang : [args.lang]) : null) ?? null,
      sTheme: __request.args.theme ?? args.theme ?? null,
      bIncToc: __request.args.inctoc ?? args.inctoc ?? true,
      bIncTocCom: __request.args.inctoccom ?? args.inctoccom ?? true
    };
    //Web.Pre(Json.Format(mPars));
    
    //Get Language(s)
    var sLang=null;
    var slLang=null;
    var smDesc=mPars.smDesc;
    if (mPars.slLang==null) {
      let sLang=String.ToLower(mPars.mPage.language);
      if (sLang not in ["en","es","eu"])
        let sLang='en';  //by default
      let slLang= [sLang];
      let smDesc..={ (sLang) : smDesc["__"] };
    }//if
    else {
      //@himikel #mod 2011-02-02: Set Current Language with '*'
      var nMainLang=0;
      foreach (var sLang in mPars.slLang)
      {
        if (String.StartsWith(sLang,"*"))
        {
          let nMainLang=__index;
          let sLang=String.SubStr(sLang,1);
        }//if
        if (sLang not in ["en","es","eu"])
          let sLang='en';  //by default
        if (sLang not in slLang)
          let slLang..= [sLang];
      }
      let sLang=slLang[nMainLang]; //set main language
    }//el
    //Web.Pre(sLang);
    //Web.Pre(Json.Format(smDesc));
    //Web.Pre(Json.Format(slLang));
    
    //Set Main Theme
    var smLangThemes= { en: "pink", es: "orange", eu: "green" };
    var sTheme= (mPars.sTheme ? String.ToLower(mPars.sTheme) : null) ?? smLangThemes[sLang] ?? "white";
    //Web.Pre(Json.Format(sTheme));
    
    //Set Theme Colors
    var sLgtCol,sDrkCol;
    var smLgtCol= { pink: "rgb(255, 204, 255)", orange: "rgb(255, 204, 153)", green: "rgb(204, 255, 204)", white: "white" };
    var smDrkCol= { pink: "rgb(204, 153, 255)", orange: "rgb(255, 153, 0)", green: "rgb(51, 153, 102)", white: "white" };
    var sLgtCol=smLgtCol[sTheme];
    var sDrkCol=smDrkCol[sTheme];
    
    //Comppose Description Line
    if (smDesc!=null) {
      var sDescLine="<p>";
      foreach (var sLang1 in slLang)
      {
        if (__index>0) let sDescLine..="&nbsp;&nbsp;";
        var sTheme1= (mPars.sTheme ? String.ToLower(mPars.sTheme) : null) ?? smLangThemes[sLang1] ?? "white";  
        var sLgtCol1=smLgtCol[sTheme1];
        var sDesc=smDesc[sLang1];
        if (String.IndexOf(sDesc,"<br />")!=0)
          let sDesc="&nbsp;"..sDesc.."&nbsp;";
        else
          let sDesc="<br />&nbsp;"..String.SubStr(sDesc,6).."&nbsp;";
        let sDescLine..="<span style='background-color: "..sLgtCol1..";'>"..sDesc.."</span>";
      }
      let sDescLine..="</p>";
      Web.Html(sDescLine);
    }//if
    
    if (mPars.bIncToc)
    {
      //var sPageToc1=Wiki.Toc('/');
      //Web.Text(sPageToc1);
      //Web.Text(Page.Toc);  
    
      //Prepare Page Toc: Interactive Discussion
      var smIntComSect={
        en: "Interactive discussion",
        es: "Discusión interactiva",
        eu: "Eztabaida interaktiboa"
      };
      var smIntComMark={
        en: ".3a)_Interactive_discussion",
        es: ".3a)_Discusi.c3.b3n_interactiva",
        eu: ".3a)_Eztabaida_interaktiboa"
      };
    
      var sIntComSect=smIntComSect[sLang];
      var sIntComMark=smIntComMark[sLang];
      //var sIntComMark="IC";
      var sIntComLi="<li><span>:) </span><a href='#"..sIntComMark.."' rel='internal'>"..sIntComSect.."</a></li>";  
      
      //Web.Pre(Json.Format(Web.Text(Wiki.Toc(mPars.mPage.parent.path))));
    
      //Set Page Toc
      //Web.Pre("PagePath: "..mPars.mPage.Path);  
      var sPageTocUri=Site.Uri.."@api/deki/pages/=Template:@himikel%252FWikiToc/contents?mode=view&format=xhtml&pageid=1&path="..Uri.Encode(mPars.mPage.Path).."&authtoken="..user.authtoken;
      //Web.Pre("PageTocUri: "..sPageTocUri);
      var xPageToc=Web.Html(sPageTocUri);
      //var xPageToc=Web.Html(Site.Uri.."/@api/deki/pages/=Template:@himikel%252FWikiToc/contents?mode=view&format=xhtml&pageid=1&path=/MindTouch/DekiMVC");
      //var xPageToc=Wiki.Template("Template:@himikel/WikiToc", { path: "/MindTouch/DekiMVC/" });
      //var xPageToc=Wiki.Toc("/MindTouch/DekiMVC");
      //var xPageToc=Wiki.Toc(mPars.mPage.Path);
      var sPageToc=Web.Text(xPageToc);
      let sPageToc=String.Replace(sPageToc,"\n","");
      //var sPageToc=Xml.Text{ doc: xPageToc, xml: true };
      //Web.Pre(Json.Format(sPageToc));
      
      //Add Comments section in Toc
      if (mPars.bIncTocCom)
      {
        if (String.IndexOf(sPageToc,"<div class=\"wiki-toc\"><em>")>=0) //No Headers
        //if (String.IndexOf(sPageToc,"<div class=\"wiki-toc\"><em>No headers</em></div>")>=0) //No Headers
        {
          let sPageToc="<div class='wiki-toc'><ol style='list-style-type:none; margin-left:0px; padding-left:0px;'>";
          let sPageToc..=sIntComLi;
          let sPageToc..="</ol></div>";
        }//if
        else
        {
          var nEndOlPos=0;
          if (sPageToc!="")
            let nEndOlPos=String.LastIndexOf(sPageToc,"</ol>");
          if (nEndOlPos>0)
            let sPageToc=String.SubStr(sPageToc,0,nEndOlPos)..sIntComLi..String.SubStr(sPageToc,nEndOlPos);
        }//el
      }//if
    
      //Contents & Navigation table
      var xPageTree=Wiki.Template("Template:@neilw/AjaxWikiTree", { path: mPars.mPage.path, secure: true });
      //var xPageTree=Wiki.Template("Template:@himikel/WikiTree", { path: mPars.mPage.path, secure: true });
      //Web.Pre(Json.Format(xPageTree));
      //var xPageTree=AjaxWikiTree{ path: mPars.mPage.path, secure: true };  
      var xlPageTreeScript=Xml.List{ doc: xPageTree, xpath: "//script", xml: true };
      var xPageTreeDiv=xPageTree["//body"];
      //var xPageTreeDiv=xPageTree["//div"];
      var sPageTreeDiv=Xml.Text{ doc: xPageTreeDiv, xml: true };
      //Web.Pre(Json.Format(sPageTreeDiv));
      //Web.Pre(Json.Format(Xml.List{ doc: xPageTree, xpath: "//*", xml: true }));
      var sContNavTable="
    <table cellspacing='1' cellpadding='1' border='0' style='width: 100%; table-layout: fixed;'>
        <tbody>
            <tr>
                <td valign='top' style='width: 45%;'>
                    <span style='font-size: medium;'><strong><span style='background-color: "..sDrkCol..";'>
                        &nbsp;v&nbsp;
                    </span></strong></span>
                    "..sPageToc.."
                </td>
                <td valign='top' style='width: 5%;'>
                    <span style='font-size: medium;'><strong><span style='background-color: "..sDrkCol..";'>
                        <a title='..' href='"..mPars.mPage.parent.path.."'>&nbsp;&lt;&nbsp;</a> <br />
                    </span></strong></span>
                </td>
                <td valign='top' style='width: 50%;'>
                    <span style='font-size: medium;'><strong><span style='background-color: "..sDrkCol..";'>
                        &nbsp;&gt;&nbsp;
                    </span></strong></span>
                    "..sPageTreeDiv.."
                </td>
            </tr>
        </tbody>
    </table>";
      Web.Html(sContNavTable);
      //Add JavaScripts
      foreach (var xPageTreeScript in xlPageTreeScript)
        Web.Xml(xPageTreeScript);
    }//if
    

     

    Webgune hau MindTouch Core "DekiWiki" software askearekin dabil

    Hemengo edukiak Creative Commons BY-NC-SA baimen baten mende daude