/war/src/main/webapp/plugins/symphony-news-getter/plugin.ftl

http://github.com/b3log/b3log-solo · Freemarker Template · 64 lines · 57 code · 7 blank · 0 comment · 0 complexity · d62499413dc9392eebf32abc1cdf31db MD5 · raw file

  1. <link type="text/css" rel="stylesheet" href="${staticServePath}/plugins/symphony-news-getter/style.css"/>
  2. <div id="symphonyNewsGetterPanel">
  3. <div class="module-panel">
  4. <div class="module-header">
  5. <h2>${b3logAnnounceLabel}</h2>
  6. </div>
  7. <div class="module-body padding12">
  8. <div id="symphonyNewsGetter">
  9. </div>
  10. </div>
  11. </div>
  12. </div>
  13. <script type="text/javascript">
  14. plugins.symphonyNewsGetter = {
  15. init: function () {
  16. $("#loadMsg").text("${loadingLabel}");
  17. $("#symphonyNewsGetter").css("background",
  18. "url(${staticServePath}/images/loader.gif) no-repeat scroll center center transparent");
  19. $.ajax({
  20. url: "http://symphony.b3log.org:80/get-news",
  21. type: "GET",
  22. dataType:"jsonp",
  23. jsonp: "callback",
  24. error: function(){
  25. $("#symphonyNewsGetter").html("Loading B3log Announcement failed :-(").css("background", "none");
  26. },
  27. success: function(data, textStatus){
  28. var articles = data.articles;
  29. if (0 === articles.length) {
  30. return;
  31. }
  32. var listHTML = "<ul>";
  33. for (var i = 0; i < articles.length; i++) {
  34. var article = articles[i];
  35. var articleLiHtml = "<li>"
  36. + "<a target='_blank' href='" + article.articlePermalink + "'>"
  37. + article.articleTitle + "</a>&nbsp; <span class='date'>" + $.bowknot.getDate(article.articleCreateDate, 1); + "</span></li>"
  38. listHTML += articleLiHtml
  39. }
  40. listHTML += "</ul>";
  41. $("#symphonyNewsGetter").html(listHTML).css("background", "none");
  42. }
  43. });
  44. $("#loadMsg").text("");
  45. }
  46. };
  47. /*
  48. * ????
  49. */
  50. admin.plugin.add({
  51. "id": "symphonyNewsGetter",
  52. "path": "/main/panel1",
  53. "content": $("#symphonyNewsGetterPanel").html()
  54. });
  55. // ??????
  56. $("#symphonyNewsGetterPanel").remove();
  57. </script>