blob: 7626cbfc11258a296aee39741a463fd8d23b3dff (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 | exports.SiteMap = SiteMap;
/**
 * @see http://www.sitemaps.org/protocol.php
 *
 * @param docs
 * @returns {SiteMap}
 */
function SiteMap(docs){
  this.render = function(){
    var map = [];
    map.push('<?xml version="1.0" encoding="UTF-8"?>');
    map.push('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
    docs.forEach(function(doc){
      map.push(' <url><loc>http://docs.angularjs.org/#!/' +
                            encode(doc.section) + '/' +
                            encode(doc.name) +
                     '</loc><changefreq>weekly</changefreq></url>');
    });
    map.push('</urlset>');
    map.push('');
    return map.join('\n');
  };
  function encode(text){
    return text
      .replace(/&/mg, '&')
      .replace(/</mg, '<')
      .replace(/>/mg, '>')
      .replace(/'/mg, ''')
      .replace(/"/mg, '"');
  }
}
 |