Debug.rythm

From BITPlan Wiki
Jump to navigation Jump to search

Links

Source

@// Rythm template for the WikiCMS approach
@import com.bitplan.smw.PropertyMap
@import com.bitplan.mediawiki.japi.api.DataItem
@import com.bitplan.mediawiki.japi.api.Property
@import javax.ws.rs.core.UriInfo
@args() {
  UriInfo uriInfo,
  String content,
  String lang,
  String title,
  PropertyMap smwprops; 
}
@{
  String server="http://wiki.bitplan.com";
  // see https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/i18n/extra/en.json
  Map<String,String> specPropsMap=new HashMap<String,String>();
  specPropsMap.put("_ASK"   , "Has query");
  specPropsMap.put("_ASKCO" , "Query scode");
  specPropsMap.put("_ASKDE" , "Query depth");
  specPropsMap.put("_ASKDU" , "Query duration");
  specPropsMap.put("_ASKFO" , "Query format");
  specPropsMap.put("_ASKPA" , "Query parameters");
  specPropsMap.put("_ASKSC" , "Query source");
  specPropsMap.put("_ASKSI" , "Query size");
  specPropsMap.put("_ASKST" , "Query string");
  specPropsMap.put("_CDAT"  , "Creation date");
  specPropsMap.put("_CHGPRO", "Change propagation");
  specPropsMap.put("_CONV"  , "Corresponds to");
  specPropsMap.put("_DTITLE", "Display title of");
  specPropsMap.put("_EDIP"  , "Is edit protected");
  specPropsMap.put("_ERRC"  , "Has processing error");
  specPropsMap.put("_ERRP"  , "Has improper value for");
  specPropsMap.put("_ERRT"  , "Has processing error text");
  specPropsMap.put("_IMPO"  , "Imported from");
  specPropsMap.put("_LCODE" , "Language code");
  specPropsMap.put("_LEDT"  , "Last editor is");
  specPropsMap.put("_LIST"  , "Has fields");
  specPropsMap.put("_MDAT"  , "Modification date");
  specPropsMap.put("_MEDIA" , "Media type");
  specPropsMap.put("_MIME"  , "MIME type");
  specPropsMap.put("_NEWP"  , "Is a new page");
  specPropsMap.put("_PDESC" , "Has property description");
  specPropsMap.put("_PEFU"  , "External formatter URI");
  specPropsMap.put("_PEID"  , "External identifier");
  specPropsMap.put("_PPLB"  , "Has preferred property label");
  specPropsMap.put("_PREC"  , "Display precision of");
  specPropsMap.put("_PVAL"  , "Allows value");
  specPropsMap.put("_PVALI" , "Allows value list");
  specPropsMap.put("_PVAP"  , "Allows pattern");
  specPropsMap.put("_PVUC"  , "Has uniqueness constraint");
  specPropsMap.put("_SERV"  , "Provides service");
  specPropsMap.put("_SOBJ"  , "Has subobject");
  specPropsMap.put("_SUBC"  , "Subcategory of");
  specPropsMap.put("_SUBP"  , "Subproperty of");
  specPropsMap.put("_TEXT"  , "Text");
  specPropsMap.put("_TYPE"  , "Has type");
  specPropsMap.put("_UNIT"  , "Display units");
  specPropsMap.put("_URI"   , "Equivalent URI");
}
@// get the Property name
@def String getProp(String prop,Map<String,String> specPropsMap) {
  if (specPropsMap.containsKey(prop)) {
    return specPropsMap.get(prop);
  } 
  return prop;
}
<!doctype html>
<html lang="@(lang)">
<head>
  <!-- https://de.wikipedia.org/wiki/Bootstrap_(Framework) -->
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>@(title)</title>
    <!-- Einbinden des Bootstrap-Stylesheets -->
    <link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css">

    <!-- optional: Einbinden der jQuery-Bibliothek -->
    <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.4.min.js"></script>

    <!-- optional: Einbinden der Bootstrap-JavaScript-Plugins -->
    <script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"></script>
    <style>
/** Language styles */

span.lang-de, span.lang-De {
	padding-right: 25px;
	background: url(@(server)/images/e/e7/Lang-De.gif) center right no-repeat;
}

span.lang-en, span.lang-En {
	padding-right: 25px;
	background: url(@(server)/images/7/78/Lang-En.gif) center right no-repeat;
}
     </style>
  </head>

<body>
    <header>
@{
  Map<String, Property> propertyMap=smwprops.getMap();
  Object languageCodeObj=smwprops.get("_LCODE");
  String languageCode="de";
  if (languageCodeObj!=null) {
    languageCode=languageCodeObj.toString();
  }
}
    </header>
    <section class="container">
   <h2>UriInfo</h2>
path=@(uriInfo.getAbsolutePath())
<h3>Query parameters</h3>
@for(String key:uriInfo.getQueryParameters().keySet()) {
@(key)=@(uriInfo.getQueryParameters().getFirst(key))
}
   <h2>Language settings</h2>
Lang: @(lang)
languageCode: @(languageCode) @(languageCodeObj.getClass().getName())
      <h2>SMW Properties</h2>
      <!-- Tabelle mit abwechselnder Zellenhintergrundfarbe und Außenrahmen -->
      <table class="table table-striped table-bordered">
        <thead>
          <tr>
            <th>#</th>
            <th>#</th>
            <th>Name</th>
            <th>Label</th>
            <th>Value</th>
            <th>Type</th>
          </tr>
        </thead>
        <tbody>
@{int index=1;}
        @for(String key:propertyMap.keySet()) {
@{
  Property prop = propertyMap.get(key);
  int size=0;
  List<DataItem> dataitems = prop.getDataitem();
  if (dataitems != null) {
    size=dataitems.size();
  }
}
          <tr>
            <td>@(index++)</td>
            <td>1</td>
            <td><a href='@(server)/index.php?title=Property:@(getProp(key,specPropsMap))'>@(getProp(key,specPropsMap))</a></td>
            <td>@(key)</td>
@if (dataitems != null) {
@{int dindex=1;}
   @for(DataItem dataitem:dataitems) {
@if (dindex>1) {
          <tr>
            <td></td>
            <td>@(dindex)</td>
            <td></td>
            <td></td>
}
            <td>@(dataitem.getItem())</td>
            <td>@(dataitem.getType())</td>
@{dindex++;}
           </tr>
   }
}
        }
        </tbody>
      </table>
      <article>@(content)</article>
    </section>
  </body>
</html>