article.art 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. {{extend './common/layout.art'}}
  2. {{block 'main'}}
  3. <!-- 子模板的相对路径相对的是当前文件,因为它是由模板引擎解析的,而不是浏览器-->
  4. {{include './common/header.art'}}
  5. <!-- 主体内容 -->
  6. <div class="content">
  7. {{include './common/sider.art'}}
  8. <div class="main">
  9. <!-- 分类标题 -->
  10. <div class="title">
  11. <h4>文章</h4>
  12. <span>找到1篇文章</span>
  13. <a href="/admin/article-edit" class="btn btn-primary new">发布新文章</a>
  14. </div>
  15. <!-- /分类标题 -->
  16. <!-- 内容列表 -->
  17. <table class="table table-striped table-bordered table-hover custom-table">
  18. <thead>
  19. <tr>
  20. <th>ID</th>
  21. <th>标题</th>
  22. <th>发布时间</th>
  23. <th>作者</th>
  24. <th>操作</th>
  25. </tr>
  26. </thead>
  27. <tbody>
  28. {{each articles.records}}
  29. <tr>
  30. <td>{{@$value._id}}</td>
  31. <td>{{$value.title}}</td>
  32. <td>{{dateformat($value.publishDate, 'yyyy-mm-dd')}}</td>
  33. <td>{{$value.author.username}}</td>
  34. <td>
  35. <a href="/admin/article-edit?id={{@$value._id}}" class="glyphicon glyphicon-edit"></a>
  36. <i class="glyphicon glyphicon-remove delete" data-toggle="modal" data-target=".confirm-modal" data-id="{{@$value._id}}"></i>
  37. </td>
  38. </tr>
  39. {{/each}}
  40. </tbody>
  41. </table>
  42. <!-- /内容列表 -->
  43. <!-- 分页 -->
  44. <ul class="pagination">
  45. {{if articles.page > 1}}
  46. <li>
  47. <a href="/admin/article?page={{articles.page - 1}}">
  48. <span>&laquo;</span>
  49. </a>
  50. </li>
  51. {{/if}}
  52. {{each articles.display}}
  53. <li><a href="/admin/article?page={{$value}}">{{$value}}</a></li>
  54. {{/each}}
  55. {{if articles.page < articles.pages}}
  56. <li>
  57. <a href="/admin/article?page={{articles.page - 0 + 1}}">
  58. <span>&raquo;</span>
  59. </a>
  60. </li>
  61. {{/if}}
  62. </ul>
  63. <!-- /分页 -->
  64. </div>
  65. </div>
  66. <!-- /主体内容 -->
  67. <!-- 删除确认弹出框 -->
  68. <div class="modal fade confirm-modal">
  69. <div class="modal-dialog modal-lg">
  70. <form class="modal-content" action="/admin/article-delete">
  71. <div class="modal-header">
  72. <button type="button" class="close" data-dismiss="modal"><span>&times;</span></button>
  73. <h4 class="modal-title">请确认</h4>
  74. </div>
  75. <div class="modal-body">
  76. <p>您确定要删除这篇文章吗?</p>
  77. <input type="hidden" name="id" id="id">
  78. </div>
  79. <div class="modal-footer">
  80. <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
  81. <input type="submit" class="btn btn-primary">
  82. </div>
  83. </form>
  84. </div>
  85. </div>
  86. <!-- /删除确认弹出框 -->
  87. {{/block}}
  88. {{block 'script'}}
  89. <script>
  90. $('.delete').on('click', function () {
  91. $('#id').val($(this).attr('data-id'));
  92. })
  93. </script>
  94. {{/block}}