Updated google plusone and facebook like buttons
[beagleboard.org.git] / code / Page / list.js
blob7266fb635372ff30b0a7b39d98e8be77da2cf104
1 function list_action ()
2  {
3   // Handles action for displaying the children of a page
4   res.handlers["User"] = User();
5   res.data.title = this.uri + " - list";
6   res.data.body = this.listBody();
7   renderSkin("index");
8  }
10 function listBody ()
11  {
12   var body = "";
13   try
14    {
15     var orderedByDate = this.getOrderedView("time desc");
16     var collection = orderedByDate.list();
17    }
18   catch (ex)
19    {
20     var collection = [];
21     body = "<p>No children exist for this page</p>\n";
22     return (body);
23    }
24    
25   function fixUrl(param)
26    {
27     param = "" + param;
28     if (param.search("http://") == -1 && param.search("https://") == -1) 
29      param = "http://" + param;
30     return (param);
31    }
32    
33   if (collection[0].render_skin == "project")
34    body += "<table id='projects'>\n";
35   if (collection[0].render_skin == "cape")
36    {
37     body += "<table id='capes' border='1'>\n";
38     body += "<tr><th>Entry</th><th>Description</th>";
39     body += "<th>Youtube Video</th></tr>\n";
40    }
41   else
42    body += "<ul>\n";
43   for (var i in collection)
44    {
45     if (collection[i].render_skin == "project")
46      {
47       body +=
48        '<tr><td><a href="' + collection[i].href() + '">'
49        + collection[i].pname
50        + '</a><br><small>' 
51        ;
52       if (("" + collection[i].homepage) != "")
53        {
54         body += ''
55          + '[<a href="'
56          + fixUrl(collection[i].homepage)
57          + '" target="_blank">homepage</a>] '
58          ;
59        }
60       if (("" + collection[i].rssfeed) != "")
61        {
62         body += ''
63          + '[<a href="'
64          + fixUrl(collection[i].rssfeed)
65          + '" target="_blank">rss</a>]'
66          ;
67        }
68       body += '</small></td>';
69       body += '<td><div class="wants-g-plusone" data-href="'
70        + 'http://beagleboard.org' + collection[i].href()
71        + '" data-size="small">'
72        + '</div></td>';
73       body += '<td><small>'
74        + encode(collection[i].shortdesc)
75        + '</small></td><td><small>Registered by: '
76        + collection[i].registrant
77        + '<br>Updated: '
78        + collection[i].time
79        + '</small></td></tr>\n'
80        ;
81      }
82     else if (collection[i].render_skin == "cape")
83      {
84       body += '<tr>\n';
85       body +=
86        ' <td><a href="' + collection[i].href() + '">'
87        + collection[i].uri
88        + '</a>' 
89        + ' by '
90        + collection[i].name
91        + '<br /><br /><div class="fb-like" data-send="false" data-width="40" data-layout="button_count" data-show-faces="false" href="'
92        + 'http://beagleboard.org' + collection[i].href()
93        + '">'
94        + '</div>'
95        + '<br /><br /><div class="wants-g-plusone" data-href="'
96        + 'http://beagleboard.org' + collection[i].href()
97        + '" data-size="small">'
98        + '</div>'
99        + '</td>\n' 
100        ;
101       body += ' <td width="300">' + collection[i].body + '</td>\n';
102       if (collection[i].youtube_url)
103        {
104         var embed = ('' + collection[i].youtube_url).match(/(youtu.be|youtube.com)\/(.*)$/);
105         if (embed && embed.length == 3)
106          {
107           body += ' <td><iframe width="412" height="240" ';
108           body += 'src="http://www.youtube.com/embed/'
109           body += embed[2];
110           body += '" frameborder="0" allowfullscreen></iframe></td>\n';
111          }
112        }
113       body += '</tr>\n';
114      }
115     else if (collection[i].render_skin == "rss")
116      {
117       body +=
118        '<li class="rss"><a href="' + collection[i].href() + '">'
119        + collection[i].uri
120        + '</a>'
121        + '<div>'
122        + collection[i].body
123        + '</div></li>\n';
124      }
125     else
126      {
127       body +=
128        '<li><a href="' + collection[i].href() + '">'
129        + collection[i].uri
130        + '</a>&nbsp;&nbsp;&nbsp;&nbsp;<small>Last updated by: '
131        + collection[i].user
132        + '</small></li>\n';
133      }
134    }
135   if (collection[0].render_skin == "project")
136    body += "</table>\n";
137   else if (collection[0].render_skin == "cape")
138    body += "</table>\n";
139   else
140    body += "</ul>\n";
141   return (body);