2
0

page.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. {% extends 'layout/2column.html' %}
  2. {% block html_title %}{{ path|path2name }} · {{ path }}{% endblock %}
  3. {% block content_head %}
  4. <div class="header-wrap">
  5. <header id="page-header">
  6. <p class="stopper"><a href="#" data-affix-disable="#page-header"><i class="fa fa-chevron-up"></i></a></p>
  7. <h1 class="title" id="revision-path">{{ path }}</h1>
  8. </header>
  9. </div>
  10. {% endblock %}
  11. {% block content_main %}
  12. <div id="content-main" class="content-main {% if not page %}on-edit{% endif %}" data-page-id="{% if page %}{{ page._id.toString() }}{% endif %}">
  13. {% if not page %}
  14. <ul class="nav nav-tabs hidden-print">
  15. <li><a>ページ作成: {{ path|path2name }}</a></li>
  16. <li class="dropdown pull-right">
  17. <a href="/"><i class="fa fa-times"></i> キャンセル</a>
  18. </li>
  19. </ul>
  20. <div class="tab-content">
  21. <div class="edit-form">
  22. {% include '_form.html' %}
  23. </div>
  24. </div>
  25. {% else %}
  26. <ul class="nav nav-tabs hidden-print">
  27. <li class=" {% if not req.body.pageForm %}active{% endif %}" data-toggle="tooltip" {# data-title="あなたの 確認待ち です" title="" data-placement="bottom" data-trigger="manual" data-tooltip-stay #}>
  28. <a href="#revision-body" data-toggle="tab">
  29. <i class="fa fa-magic"></i>
  30. {#
  31. <img src="//graph.facebook.com/588883490/picture?size=square" width="16"> <i class="fa fa-arrow-right"></i> <img src="//graph.facebook.com/588883490/picture?size=square" width="16">
  32. <span class="label label-danger" style=""> 承認待ち</span>
  33. #}
  34. </a>
  35. </li>
  36. <li {% if req.body.pageForm %}class="active"{% endif %}><a href="#edit-form" data-toggle="tab"><i class="fa fa-pencil-square-o"></i> 編集</a></li>
  37. <li class="dropdown pull-right">
  38. <a class="dropdown-toggle" data-toggle="dropdown" href="#">
  39. <i class="fa fa-wrench"></i> <span class="caret"></span>
  40. </a>
  41. <ul class="dropdown-menu">
  42. <li><a href="#" data-target="#renamePage" data-toggle="modal"><i class="fa fa-share"></i> 移動</a></li>
  43. <li><a href="?presentation=1" class="toggle-presentation"><i class="fa fa-arrows-alt"></i> プレゼンモード (beta)</a></li>
  44. </ul>
  45. </li>
  46. </ul>
  47. {% include 'modal/widget_rename.html' %}
  48. <div class="tab-content wiki-content">
  49. {% if req.query.renamed %}
  50. <div class="alert alert-info">
  51. <strong>移動しました: </strong> このページは <code>{{ req.query.renamed }}</code> から移動しました。
  52. </div>
  53. {% endif %}
  54. {% if not page.isLatestRevision() %}
  55. <div class="alert alert-warning">
  56. <strong>注意: </strong> これは現在の版ではありません。
  57. </div>
  58. {% endif %}
  59. {#
  60. <div class="panel panel-default">
  61. <div class="panel-heading">承認待ち</div>
  62. <div class="panel-body">
  63. ほげほげ
  64. </div>
  65. </div>
  66. #}
  67. <script type="text/template" id="raw-text-original">{{ revision.body }}</script>
  68. {# formatted text #}
  69. <div class="tab-pane {% if not req.body.pageForm %}active{% endif %}" id="revision-body">
  70. <div class="revision-toc" id="revision-toc">
  71. <a data-toggle="collapse" data-parent="#revision-toc" href="#revision-toc-content" class="revision-toc-head collapsed">目次</a>
  72. </div>
  73. <div class="wiki {{ revision.format }}" id="revision-body-content"></div>
  74. </div>
  75. {# raw text #}
  76. <div class="tab-pane" id="raw-text">
  77. <pre id="">{{ revision.body }}</pre>
  78. </div>
  79. {# edit form #}
  80. <div class="edit-form tab-pane {% if req.body.pageForm %}active{% endif %}" id="edit-form">
  81. {% include '_form.html' %}
  82. </div>
  83. </div>
  84. <script type="text/javascript">
  85. $(function(){
  86. var renderer = new Crowi.renderer($('#raw-text-original').html());
  87. renderer.render();
  88. Crowi.correctHeaders('#revision-body-content');
  89. Crowi.revisionToc('#revision-body-content', '#revision-toc');
  90. $('a[data-toggle="tab"][href="#edit-form"]').on('show.bs.tab', function() {
  91. $('.content-main').addClass('on-edit');
  92. });
  93. $('a[data-toggle="tab"][href="#edit-form"]').on('hide.bs.tab', function() {
  94. $('.content-main').removeClass('on-edit');
  95. });
  96. $('#edit-form').submit(function()
  97. {
  98. //console.log('save');
  99. //return false;
  100. });
  101. //data-spy="affix" data-offset-top="80"
  102. var headerHeight = $('#page-header').outerHeight(true);
  103. $('.header-wrap').css({height: headerHeight + 'px'});
  104. $('#page-header').affix({
  105. offset: {
  106. top: function() {
  107. return headerHeight + 74; // (54 header + 20 padding-top)
  108. }
  109. }
  110. });
  111. $('[data-affix-disable]').on('click', function(e) {
  112. $elm = $($(this).data('affix-disable'));
  113. $(window).off('.affix');
  114. $elm.removeData('affix').removeClass('affix affix-top affix-bottom');
  115. return false;
  116. });
  117. });
  118. </script>
  119. {% endif %}
  120. </div>
  121. {% endblock %}
  122. {% block content_footer %}
  123. <div class="page-attachments">
  124. <p>Attachments</p>
  125. <ul>
  126. </ul>
  127. </div>
  128. <script>
  129. (function() {
  130. var pageId = $('#content-main').data('page-id');
  131. var $pageAttachmentList = $('.page-attachments ul');
  132. if (pageId) {
  133. $.get('/_api/attachment/page/' + pageId, function(res) {
  134. var attachments = res.data.attachments;
  135. var urlBase = res.data.fileBaseUrl;
  136. if (attachments.length > 0) {
  137. $.each(attachments, function(i, file) {
  138. $pageAttachmentList.append(
  139. '<li><a href="' + urlBase + file.filePath + '">' + (file.originalName || file.fileName) + '</a> <span class="label label-default">' + file.fileFormat + '</span></li>'
  140. );
  141. })
  142. } else {
  143. $('.page-attachments').remove();
  144. }
  145. });
  146. }
  147. })();
  148. </script>
  149. <footer>
  150. {% if not page %}
  151. {% else %}
  152. <p class="meta">
  153. Path: <span id="pagePath">{{ page.path }}</span><br />
  154. Revision: {{ revision._id.toString() }}<br />
  155. {% if author %}
  156. Last Updated User: <a href="/user/{{ author.username }}">{{ author.name }}</a><br />
  157. {% endif %}
  158. Created: {{ page.createdAt|datetz('Y-m-d H:i:s') }}<br />
  159. Updated: {{ page.updatedAt|datetz('Y-m-d H:i:s') }}<br />
  160. </p>
  161. {% endif %}
  162. </footer>
  163. {% endblock %}
  164. {% block side_header %}
  165. {% if page %} {# {{{ if page #}
  166. <div class="page-meta">
  167. <div class="row">
  168. {# default(author) としているのは、v1.1.1 以前に page.creator データが入ってないから。暫定として最新更新ユーザーを表示しちゃう。 #}
  169. <div class="col-md-3 creator-picture">
  170. <img src="{{ page.creator|default(author)|picture }}" class="picture picture-lg picture-rounded"><br>
  171. </div>
  172. <div class="col-md-9">
  173. <p class="creator">
  174. {{ page.creator.name|default(author.name) }}
  175. </p>
  176. <p class="created-at">
  177. 作成日: {{ page.createdAt|datetz('Y/m/d H:i:s') }}<br>
  178. 最終更新: {{ page.updatedAt|datetz('Y/m/d H:i:s') }} <a href="/user/{{ author.username }}"><img src="{{ author|picture }}" class="picture picture-xs picture-rounded" alt="{{ author.name }}"></a>
  179. </p>
  180. </div>
  181. </div>
  182. <div class="like-box">
  183. <dl class="dl-horizontal">
  184. <dt>
  185. <i class="fa fa-star"></i> お気に入り
  186. </dt>
  187. <dd>
  188. <button class="btn btn-default btn-sm btn-bookmark" id="bookmarkButton"><i class="fa fa-star-o"></i></button>
  189. </dd>
  190. <dt>
  191. <i class="fa fa-thumbs-o-up"></i> いいね!
  192. </dt>
  193. <dd>
  194. <p class="liker-count">
  195. {{ page.liker.length }}
  196. </p>
  197. <p class="liker-list">
  198. {% for liker in page.liker %}
  199. <a href="{{ user_page_root(liker) }}" title="{{ liker.name }}"><img alt="{{ liker.name }}" src="{{ liker|picture }}" class="picture picture-xs picture-rounded"></a>
  200. {% endfor %}
  201. {% if page.liker.length > 10 %}
  202. (...)
  203. {% endif %}
  204. </p>
  205. {% if page.isLiked(user) %}
  206. <button data-liked="1" class="btn btn-default btn-sm active" id="pageLikeButton"><i class="fa fa-thumbs-up"></i> いいね!!!</button>
  207. {% else %}
  208. <button data-liked="0" class="btn btn-default btn-sm" id="pageLikeButton"><i class="fa fa-thumbs-o-up"></i> いいね!!!</button>
  209. {% endif %}
  210. </dd>
  211. <dt><i class="fa fa-eye"></i> 見た人</dt>
  212. <dd>
  213. <p class="seen-user-count">
  214. {{ page.seenUsers.length }}
  215. </p>
  216. <p class="seen-user-list">
  217. {% for seenUser in page.seenUsers %}
  218. <a href="{{ user_page_root(seenUser) }}" title="{{ seenUser.name }}"><img alt="{{ seenUser.name }}" src="{{ seenUser|picture }}" class="picture picture-xs picture-rounded"></a>
  219. {% endfor %}
  220. {% if page.seenUsers.length > 10 %}
  221. (...)
  222. {% endif %}
  223. </p>
  224. </dd>
  225. </dl>
  226. </div>
  227. <script>
  228. $(function() {
  229. $.get('/_api/page/{{ page._id.toString() }}/bookmark', function(data) {
  230. if (data.bookmarked) {
  231. $('#bookmarkButton')
  232. .removeClass('btn-default')
  233. .addClass('btn-warning active bookmarked');
  234. $('#bookmarkButton i')
  235. .removeClass('fa-star-o')
  236. .addClass('fa-star');
  237. }
  238. });
  239. $('#bookmarkButton').click(function() {
  240. var pageId = {{page._id|json|safe}};
  241. $.post('/_api/page/{{ page._id.toString() }}/bookmark', function(data) {
  242. });
  243. });
  244. $('#pageLikeButton').click(function() {
  245. var pageId = {{page._id|json|safe}};
  246. $.post('/_api/page/{{ page._id.toString() }}/like', function(data) {
  247. });
  248. });
  249. });
  250. </script>
  251. </div>
  252. {% endif %} {# if page }}} #}
  253. {% endblock %} {# side_header #}
  254. {% block side_content %}
  255. <h3><i class="fa fa-link"></i> 共有</h3>
  256. <ul class="fitted-list">
  257. <li data-toggle="tooltip" data-placement="bottom" title="共有用リンク" class="input-group">
  258. <span class="input-group-addon">共有用</span>
  259. <input class="copy-link form-control" type="text" value="{{ config.crowi['app:title'] }} {{ path }} {{ baseUrl }}/_r/{{ page._id.toString() }}">
  260. </li>
  261. <li data-toggle="tooltip" data-placement="bottom" title="Wiki記法" class="input-group">
  262. <span class="input-group-addon">Wikiタグ</span>
  263. <input class="copy-link form-control" type="text" value="&lt;{{ path }}&gt;">
  264. </li>
  265. <li data-toggle="tooltip" data-placement="bottom" title="Markdown形式のリンク" class="input-group">
  266. <span class="input-group-addon">Markdown</span>
  267. <input class="copy-link form-control" type="text" value="[{{ path }}]({{ baseUrl }}/_r/{{ revision._id.toString() }})">
  268. </li>
  269. </ul>
  270. <h3><i class="fa fa-history"></i> History</h3>
  271. {% if not page %}
  272. {% else %}
  273. <ul class="revision-history">
  274. {% for t in tree %}
  275. <li>
  276. <a href="?revision={{ t._id.toString() }}">
  277. <img src="{{ t.author|picture }}" class="picture picture-rounded">
  278. {% if t.author %}{{ t.author.username }}{% else %}-{% endif %}<br>{{ t.createdAt|datetz('Y-m-d H:i:s') }}
  279. </a>
  280. </li>
  281. {% endfor %}
  282. </ul>
  283. {% endif %}
  284. {% endblock %}
  285. {% block footer %}
  286. <div id="notifPageEdited" class="fk-hide fk-notif fk-notif-danger"><i class="fa fa-exclamation-triangle"></i> <span class="edited-user"></span>さんがこのページを編集しました。 <a href="javascript:location.reload();"><i class="fa fa-angle-double-right"></i> 最新版を読み込む</a></div>
  287. <div id="notifPageEditing" class="fk-hide fk-notif fk-notif-warning"><i class="fa fa-exclamation-triangle"></i> 他の人がこのページの編集を開始しました。</div>
  288. <script>
  289. $(function() {
  290. var me = {{ user|json|safe }};
  291. var socket = io();
  292. socket.on('page edited', function (data) {
  293. if (data.user._id != me._id
  294. && data.page.path == {{ page.path|json|safe }}) {
  295. $('#notifPageEdited').removeClass('fk-hide').css({bottom: 0});
  296. $('#notifPageEdited .edited-user').html(data.user.name);
  297. }
  298. });
  299. });
  300. </script>
  301. {% endblock %}
  302. {% block body_end %}
  303. {% parent %}
  304. <div id="presentation-layer" class="fullscreen-layer">
  305. <div id="presentation-container"></div>
  306. </div>
  307. <script>
  308. $(function() {
  309. var presentaionInitialized = false
  310. , $b = $('body');
  311. $(document).on('click', '.toggle-presentation', function(e) {
  312. var $a = $(this);
  313. e.preventDefault();
  314. $b.toggleClass('overlay-on');
  315. if (!presentaionInitialized) {
  316. presentaionInitialized = true;
  317. $('<iframe />').attr({
  318. src: $a.attr('href')
  319. }).appendTo($('#presentation-container'));
  320. }
  321. }).on('click', '.fullscreen-layer', function() {
  322. $b.toggleClass('overlay-on');
  323. });
  324. });
  325. </script>
  326. {% endblock %}