Debug.rythm

From BITPlan Wiki
Revision as of 12:20, 1 November 2017 by Wf (talk | contribs) (→‎Source)
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
@args() {
  String content,
  String lang,
  String title,
  PropertyMap smwprops; 
}
@{
  String server="http://wiki.bitplan.com";
  Map<String,String> specPropsMap=new HashMap<String,String>();
  specPropsMap.put("_MDAT","Modification_date");
}
@def String getProp(String prop) {
     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("Language_code");
  String languageCode="de";
  if (languageCodeObj!=null) {
    languageCode=languageCodeObj.toString();
  }
}
    </header>
    <section class="container">
      <h2>SMW Properties</h2>
      <!-- Tabelle mit abwechselnder Zellenhintergrundfarbe und Außenrahmen -->
      <table class="table table-striped table-bordered">
        <thead>
          <tr>
            <th>#</th>
            <th>Name</th>
            <th>Value</th>
            <th>#Data Items</th>
          </tr>
        </thead>
        <tbody>
@{int index=0;}
        @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><a href='@(server)/index.php?title=Property:@(getProp(key))'>@(key)</a></td>
            <td>@(smwprops.get(key))</td>
            <td>@(size)</td>
           </tr>
        }
        </tbody>
      </table>
      <article>@(content)</article>
    </section>
  </body>
</html>