page.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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. console.log(file);
  139. $pageAttachmentList.append(
  140. '<li><a href="' + urlBase + file.filePath + '">' + (file.originalName || file.fileName) + '</a> <span class="label label-default">' + file.fileFormat + '</span></li>'
  141. );
  142. })
  143. } else {
  144. $('.page-attachments').remove();
  145. }
  146. });
  147. }
  148. })();
  149. </script>
  150. <footer>
  151. {% if not page %}
  152. {% else %}
  153. <p class="meta">
  154. Path: <span id="pagePath">{{ page.path }}</span><br />
  155. Revision: {{ revision._id.toString() }}<br />
  156. {% if author %}
  157. Last Updated User: <a href="/user/{{ author.username }}">{{ author.name }}</a><br />
  158. {% endif %}
  159. Created: {{ page.createdAt|datetz('Y-m-d H:i:s') }}<br />
  160. Updated: {{ page.updatedAt|datetz('Y-m-d H:i:s') }}<br />
  161. </p>
  162. {% endif %}
  163. </footer>
  164. {% endblock %}
  165. {% block side_header %}
  166. {% if page %} {# {{{ if page #}
  167. <div class="page-meta">
  168. <div class="row">
  169. {# default(author) としているのは、v1.1.1 以前に page.creator データが入ってないから。暫定として最新更新ユーザーを表示しちゃう。 #}
  170. <div class="col-md-3 creator-picture">
  171. <img src="{{ page.creator|default(author)|picture }}" class="picture picture-lg picture-rounded"><br>
  172. </div>
  173. <div class="col-md-9">
  174. <p class="creator">
  175. {{ page.creator.name|default(author.name) }}
  176. </p>
  177. <p class="created-at">
  178. 作成日: {{ page.createdAt|datetz('Y/m/d H:i:s') }}<br>
  179. 最終更新: {{ 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>
  180. </p>
  181. </div>
  182. </div>
  183. <div class="like-box">
  184. <dl class="dl-horizontal">
  185. <dt>
  186. <i class="fa fa-star"></i> お気に入り
  187. </dt>
  188. <dd>
  189. <button class="btn btn-default btn-sm btn-bookmark" id="bookmarkButton"><i class="fa fa-star-o"></i></button>
  190. </dd>
  191. <dt>
  192. <i class="fa fa-thumbs-o-up"></i> いいね!
  193. </dt>
  194. <dd>
  195. <p class="liker-count">
  196. {{ page.liker.length }}
  197. </p>
  198. <p class="liker-list">
  199. {% for liker in page.liker %}
  200. <a href="{{ user_page_root(liker) }}" title="{{ liker.name }}"><img alt="{{ liker.name }}" src="{{ liker|picture }}" class="picture picture-xs picture-rounded"></a>
  201. {% endfor %}
  202. {% if page.liker.length > 10 %}
  203. (...)
  204. {% endif %}
  205. </p>
  206. {% if page.isLiked(user) %}
  207. <button data-liked="1" class="btn btn-default btn-sm active" id="pageLikeButton"><i class="fa fa-thumbs-up"></i> いいね!!!</button>
  208. {% else %}
  209. <button data-liked="0" class="btn btn-default btn-sm" id="pageLikeButton"><i class="fa fa-thumbs-o-up"></i> いいね!!!</button>
  210. {% endif %}
  211. </dd>
  212. <dt><i class="fa fa-eye"></i> 見た人</dt>
  213. <dd>
  214. <p class="seen-user-count">
  215. {{ page.seenUsers.length }}
  216. </p>
  217. <p class="seen-user-list">
  218. {% for seenUser in page.seenUsers %}
  219. <a href="{{ user_page_root(seenUser) }}" title="{{ seenUser.name }}"><img alt="{{ seenUser.name }}" src="{{ seenUser|picture }}" class="picture picture-xs picture-rounded"></a>
  220. {% endfor %}
  221. {% if page.seenUsers.length > 10 %}
  222. (...)
  223. {% endif %}
  224. </p>
  225. </dd>
  226. </dl>
  227. </div>
  228. <script>
  229. $(function() {
  230. $.get('/_api/page/{{ page._id.toString() }}/bookmark', function(data) {
  231. if (data.bookmarked) {
  232. $('#bookmarkButton')
  233. .removeClass('btn-default')
  234. .addClass('btn-warning active bookmarked');
  235. $('#bookmarkButton i')
  236. .removeClass('fa-star-o')
  237. .addClass('fa-star');
  238. }
  239. });
  240. $('#bookmarkButton').click(function() {
  241. var pageId = {{page._id|json|safe}};
  242. $.post('/_api/page/{{ page._id.toString() }}/bookmark', function(data) {
  243. });
  244. });
  245. $('#pageLikeButton').click(function() {
  246. var pageId = {{page._id|json|safe}};
  247. $.post('/_api/page/{{ page._id.toString() }}/like', function(data) {
  248. });
  249. });
  250. });
  251. </script>
  252. </div>
  253. {% endif %} {# if page }}} #}
  254. {% endblock %} {# side_header #}
  255. {% block side_content %}
  256. <h3><i class="fa fa-link"></i> 共有</h3>
  257. <ul class="fitted-list">
  258. <li data-toggle="tooltip" data-placement="bottom" title="共有用リンク" class="input-group">
  259. <span class="input-group-addon">共有用</span>
  260. <input class="copy-link form-control" type="text" value="{{ config.crowi['app:title'] }} {{ path }} {{ baseUrl }}/_r/{{ page._id.toString() }}">
  261. </li>
  262. <li data-toggle="tooltip" data-placement="bottom" title="Wiki記法" class="input-group">
  263. <span class="input-group-addon">Wikiタグ</span>
  264. <input class="copy-link form-control" type="text" value="&lt;{{ path }}&gt;">
  265. </li>
  266. <li data-toggle="tooltip" data-placement="bottom" title="Markdown形式のリンク" class="input-group">
  267. <span class="input-group-addon">Markdown</span>
  268. <input class="copy-link form-control" type="text" value="[{{ path }}]({{ baseUrl }}/_r/{{ revision._id.toString() }})">
  269. </li>
  270. </ul>
  271. <h3><i class="fa fa-history"></i> History</h3>
  272. {% if not page %}
  273. {% else %}
  274. <ul class="revision-history">
  275. {% for t in tree %}
  276. <li>
  277. <a href="?revision={{ t._id.toString() }}">
  278. <img src="{{ t.author|picture }}" class="picture picture-rounded">
  279. {% if t.author %}{{ t.author.username }}{% else %}-{% endif %}<br>{{ t.createdAt|datetz('Y-m-d H:i:s') }}
  280. </a>
  281. </li>
  282. {% endfor %}
  283. </ul>
  284. {% endif %}
  285. {% endblock %}
  286. {% block footer %}
  287. <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>
  288. <div id="notifPageEditing" class="fk-hide fk-notif fk-notif-warning"><i class="fa fa-exclamation-triangle"></i> 他の人がこのページの編集を開始しました。</div>
  289. <script>
  290. $(function() {
  291. var me = {{ user|json|safe }};
  292. var socket = io();
  293. socket.on('page edited', function (data) {
  294. if (data.user._id != me._id
  295. && data.page.path == {{ page.path|json|safe }}) {
  296. $('#notifPageEdited').removeClass('fk-hide').css({bottom: 0});
  297. $('#notifPageEdited .edited-user').html(data.user.name);
  298. }
  299. });
  300. });
  301. </script>
  302. {% endblock %}
  303. {% block body_end %}
  304. {% parent %}
  305. <div id="presentation-layer" class="fullscreen-layer">
  306. <div id="presentation-container"></div>
  307. </div>
  308. <script>
  309. $(function() {
  310. var presentaionInitialized = false
  311. , $b = $('body');
  312. $(document).on('click', '.toggle-presentation', function(e) {
  313. var $a = $(this);
  314. e.preventDefault();
  315. $b.toggleClass('overlay-on');
  316. if (!presentaionInitialized) {
  317. presentaionInitialized = true;
  318. $('<iframe />').attr({
  319. src: $a.attr('href')
  320. }).appendTo($('#presentation-container'));
  321. }
  322. }).on('click', '.fullscreen-layer', function() {
  323. $b.toggleClass('overlay-on');
  324. });
  325. });
  326. </script>
  327. {% endblock %}