page.html 14 KB

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