cacheIndex function

  1. @GenerateFor(_cacheIndex)
TrustedHtml cacheIndex(
  1. ResClient client
)

Implementation

@GenerateFor(_cacheIndex)
TrustedHtml cacheIndex(ResClient client) {
  var $ = StringBuffer();

  var rid = '';
  final rids = client.cachedRids;
  rids.sort();
  $.writeln('<!doctype html>');

  $.write('<html lang="en">');
  $.write('<head>');
  $.write('\n  ');
  $.write('<title>');
  $.write('Res Cache');
  $.write('</title>');
  $.write('\n');
  $.write('</head>');
  $.write('\n');
  $.write('<body>');
  $.write('\n  ');
  $.write('<h2>');
  $.write('Models');
  $.write('</h2>');
  $.write('\n  ');
  $.write('<ul>');
  $.write('\n    ');
  for (var rid in template.nonNullIterable(rids)) {
    $.write('<li>');
    $.write('\n      ');
    $.write('<a href="cache/${TrustedHtml.escape.attribute(rid)}">');
    $.write('${TrustedHtml.escape(rid)}');
    if (template.nonNullBool(client.get(rid)?.item is ResCollection)) {
      $.write('<span>');
      $.write(' (collection)');
      $.write('</span>');
    }
    $.write('</a>');
    $.write('\n    ');
    $.write('</li>');
  }
  $.write('\n  ');
  $.write('</ul>');
  $.write('\n\n\n  ');
  $.write('</body>');
  $.write('</html>');

  return TrustedHtml($.toString());
}