Template:LastChanges

Stránka naposledy upravena 10:08, 23 Zář 2009 uživatelem Ondřej Nešpor
    Obsah
    Žádné titulky
    // Parameters:
    //   title: The title text
    //   Path:  path to the starting page
    //   max:  Maximum number of items to list
    //   comments:  Include comment date when checking for newest changes
    //   dateformat:  Date Format mask
    //   blockstyle:  Any valid styling.  The entire template is wrapped in this template
    //   titlestyle:  Any valid styling.  This controls the title area of this template
    //   bodystyle:  Any valid styling.  This control the content or body of this template
    //   onlynew:  Only list the newest pages by original creation date. 
    /*
      In a dekiscript block:
        whatsnew2{ title: 'testing', 
                   path: '/resources', 
                   max: 5, 
                   depth: 1, 
                   comments: true, 
                   dateformat:'MM/dd/yyyy'
                 };
    
    Vesion History: 1.0 - Initial release
                    1.1 - Optimized code, added: Styles, DateFormat Options, Div Containers
                    1.2 - Changed from using div id's to div classes
                          Added the ability to order pages by original creation date
    */
    
    var title = ($0 ?? args.title ?? 'Whats New!');
    var path = ($1 ?? args.path ?? page.path);
    var maxnum = ($2 ?? args.max ?? 10);
    var depth = ($3 ?? args.depth ?? 10);
    var tstcmts = ($4 ?? args.comments ?? false);
    var dteformat = ($5 ?? args.dateformat ?? 'MM.dd.yyyy ');
    var blockstyle = ($6 ?? args.blockstyle ?? '');
    var titlestyle = ($7 ?? args.titlestyle ?? '');
    var bodystyle = ($87 ?? args.bodystyle ?? '');
    var onlynew = ($9 ?? args.onlynew ?? false);
    
    
    var cmtdte = '';
    var pagedte='';
    var latestdte='';
    var lst = [];
    var cmtoredit = '';
    
    var pxml = wiki.tree(path,depth);
       foreach(var x in  pxml["//@title"]) {
          let p = wiki.getpage(xml.text(x));
          let pagedte = p.date;
    
          if(onlynew == false) {
             if(tstcmts == true) {
                let cmtdte = (p.comments[#p.comments-1].date ?? p.date);
                // let latestdte = ((date.format(p.date,'s') > date.format(cmtdte,'s')) ? p.date : cmtdte);
                // let cmtoredit = ((date.format(p.date,'s') >= date.format(cmtdte,'s')) ? 'p' : 'c');
    
                let latestdte = ((date.compare(p.date, cmtdte) >=0 ) ? p.date : cmtdte);
                let cmtoredit = ((date.compare(p.date, cmtdte) >=0 ) ? 'p' : 'c');
    
             } else {
                let latestdte = p.date;
                let cmtoredit = 'p';
             }
    
             if (date.isvalid(latestdte)) {
                let latestdte = date.format(latestdte, 's');
                let lst ..=[ {uri: p.uri, path: p.path, title: p.title, pagedate: pagedte, cmtdate: cmtdte, latestdate: latestdte, pgorcmt: cmtoredit } ];
             }
          } else {
             let lst ..=[ {uri: p.uri, path: p.path, title: p.title, pagedate: p.date, latestdate: date.format(p.revisions[0].date,'s'), pgorcmt: 'n' } ];
          }
       }
    
    let lst = list.sort(lst, 'latestdate', true);
    <div class="whtsnew" style=(blockstyle)>
      <ul
      class="whtsnewbdy" style=(bodystyle)>
        foreach(var p in lst) {
          if(__count >= maxnum) {break;}
     
          if(p.uri) {
    <li>
           if(onlynew == false) {
              web.link(p.uri, p.title); <br /> <span style="font-size: xx-small;">;' - ' ..((p.pgorcmt == 'p') ? ' Upravena: ' : ' Comment Added on: ') ..date.format(p.latestdate, dteformat); </span> <br/>;
           } else { 
              web.link(p.uri, p.title); <span style="font-size: xx-small;">;' - ' ..' Vytvořena: ' ..date.format(p.latestdate, dteformat); </span> <br/>; 
           }
    </li>
       }
    }
    </ul>  
      
    </div>
    
    // styles
    <html>
       <head>
          <style type="text/css">"
    
              div.whtsnew {
                 width: 100%;
             
              }
        
              div.whtsnewbdy {
                 background-color: #FFF;
                 padding: 2px;
                 border-style: solid;
                 border-width: 1px;
                 text-align: left;
              }
           "
           </style>
       </head>
    </html>
    

     

    Klíčová slova (Upravit)
    • Žádná klíčová slova

    Soubory 0

     

    Komentáře

    K zasílání komentářů je nutné se přihlásit.