diff options
Diffstat (limited to 'app/views/shared/wikis')
-rw-r--r-- | app/views/shared/wikis/_form.html.haml | 79 | ||||
-rw-r--r-- | app/views/shared/wikis/_main_links.html.haml | 9 | ||||
-rw-r--r-- | app/views/shared/wikis/_pages_wiki_page.html.haml | 6 | ||||
-rw-r--r-- | app/views/shared/wikis/_sidebar.html.haml | 22 | ||||
-rw-r--r-- | app/views/shared/wikis/_sidebar_wiki_page.html.haml | 3 | ||||
-rw-r--r-- | app/views/shared/wikis/_wiki_directory.html.haml | 4 | ||||
-rw-r--r-- | app/views/shared/wikis/_wiki_page.html.haml | 1 | ||||
-rw-r--r-- | app/views/shared/wikis/edit.html.haml | 31 | ||||
-rw-r--r-- | app/views/shared/wikis/empty.html.haml | 4 | ||||
-rw-r--r-- | app/views/shared/wikis/history.html.haml | 41 | ||||
-rw-r--r-- | app/views/shared/wikis/pages.html.haml | 32 | ||||
-rw-r--r-- | app/views/shared/wikis/show.html.haml | 32 |
12 files changed, 264 insertions, 0 deletions
diff --git a/app/views/shared/wikis/_form.html.haml b/app/views/shared/wikis/_form.html.haml new file mode 100644 index 00000000000..8ea06d4d6c3 --- /dev/null +++ b/app/views/shared/wikis/_form.html.haml @@ -0,0 +1,79 @@ +- form_classes = %w[wiki-form common-note-form prepend-top-default js-quick-submit] + +- if @page.persisted? + - form_action = wiki_page_path(@wiki, @page) + - form_method = :put +- else + - form_action = wiki_path(@wiki, action: :create) + - form_method = :post + - form_classes << 'js-new-wiki-page' + += form_for @page, url: form_action, method: form_method, + html: { class: form_classes }, + data: { uploads_path: uploads_path } do |f| + = form_errors(@page, truncate: :title) + + - if @page.persisted? + = f.hidden_field :last_commit_sha, value: @page.last_commit_sha + + .form-group.row + .col-sm-12= f.label :title, class: 'control-label-full-width' + .col-sm-12 + = f.text_field :title, class: 'form-control qa-wiki-title-textbox', value: @page.title, required: true, autofocus: !@page.persisted?, placeholder: s_('Wiki|Page title') + %span.d-inline-block.mw-100.prepend-top-5 + = icon('lightbulb-o') + - if @page.persisted? + = s_("WikiEditPageTip|Tip: You can move this page by adding the path to the beginning of the title.") + = link_to icon('question-circle'), help_page_path('user/project/wiki/index', anchor: 'moving-a-wiki-page'), + target: '_blank', rel: 'noopener noreferrer' + - else + = s_("WikiNewPageTip|Tip: You can specify the full path for the new file. We will automatically create any missing directories.") + = succeed '.' do + = link_to _('Learn more'), help_page_path('user/project/wiki/index', anchor: 'creating-a-new-wiki-page'), + target: '_blank', rel: 'noopener noreferrer' + .form-group.row + .col-sm-12= f.label :format, class: 'control-label-full-width' + .col-sm-12 + .select-wrapper + = f.select :format, options_for_select(Wiki::MARKUPS, {selected: @page.format}), {}, class: 'form-control select-control' + = icon('chevron-down') + + .form-group.row + .col-sm-12= f.label :content, class: 'control-label-full-width' + .col-sm-12 + = render layout: 'shared/md_preview', locals: { url: wiki_page_path(@wiki, @page, action: :preview_markdown) } do + = render 'shared/zen', f: f, attr: :content, classes: 'note-textarea qa-wiki-content-textarea', placeholder: s_("WikiPage|Write your content or drag files hereā¦") + = render 'shared/notes/hints' + + .clearfix + .error-alert + + .form-text.text-muted + = succeed '.' do + - case @page.format.to_s + - when 'rdoc' + - link_example = '{Link title}[link:page-slug]' + - when 'asciidoc' + - link_example = 'link:page-slug[Link title]' + - when 'org' + - link_example = '[[page-slug]]' + - else + - link_example = '[Link Title](page-slug)' + = (s_('WikiMarkdownTip|To link to a (new) page, simply type <code class="js-markup-link-example">%{link_example}</code>') % { link_example: link_example }).html_safe + = succeed '.' do + - markdown_link = link_to s_("WikiMarkdownDocs|documentation"), help_page_path('user/markdown', anchor: 'wiki-specific-markdown') + = (s_("WikiMarkdownDocs|More examples are in the %{docs_link}") % { docs_link: markdown_link }).html_safe + + .form-group.row + .col-sm-12= f.label :commit_message, class: 'control-label-full-width' + .col-sm-12= f.text_field :message, class: 'form-control qa-wiki-message-textbox', rows: 18, value: nil + + .form-actions + - if @page && @page.persisted? + = f.submit _("Save changes"), class: 'btn-success btn qa-save-changes-button' + .float-right + = link_to _("Cancel"), wiki_page_path(@wiki, @page), class: 'btn btn-cancel btn-grouped' + - else + = f.submit s_("Wiki|Create page"), class: 'btn-success btn qa-create-page-button rspec-create-page-button' + .float-right + = link_to _("Cancel"), wiki_path(@wiki), class: 'btn btn-cancel' diff --git a/app/views/shared/wikis/_main_links.html.haml b/app/views/shared/wikis/_main_links.html.haml new file mode 100644 index 00000000000..e173ef72d11 --- /dev/null +++ b/app/views/shared/wikis/_main_links.html.haml @@ -0,0 +1,9 @@ +- if @page&.persisted? + - if can?(current_user, :create_wiki, @wiki.container) + = link_to wiki_path(@wiki, action: :new), class: "btn btn-success", role: "button", data: { qa_selector: 'new_page_button' } do + = s_("Wiki|New page") + = link_to wiki_page_path(@wiki, @page, action: :history), class: "btn", role: "button", data: { qa_selector: 'page_history_button' } do + = s_("Wiki|Page history") + - if can?(current_user, :create_wiki, @wiki.container) && @page.latest? && @valid_encoding + = link_to wiki_page_path(@wiki, @page, action: :edit), class: "btn js-wiki-edit", role: "button", data: { qa_selector: 'edit_page_button' } do + = _("Edit") diff --git a/app/views/shared/wikis/_pages_wiki_page.html.haml b/app/views/shared/wikis/_pages_wiki_page.html.haml new file mode 100644 index 00000000000..534884eb848 --- /dev/null +++ b/app/views/shared/wikis/_pages_wiki_page.html.haml @@ -0,0 +1,6 @@ +%li + = link_to wiki_page.title, wiki_page_path(@wiki, wiki_page) + %small (#{wiki_page.format}) + .float-right + - if wiki_page.last_version + %small= (s_("Last edited %{date}") % { date: time_ago_with_tooltip(wiki_page.last_version.authored_date) }).html_safe diff --git a/app/views/shared/wikis/_sidebar.html.haml b/app/views/shared/wikis/_sidebar.html.haml new file mode 100644 index 00000000000..8cfb95cdcf5 --- /dev/null +++ b/app/views/shared/wikis/_sidebar.html.haml @@ -0,0 +1,22 @@ +%aside.right-sidebar.right-sidebar-expanded.wiki-sidebar.js-wiki-sidebar.js-right-sidebar{ data: { "offset-top" => "50", "spy" => "affix" } } + .sidebar-container + .block.wiki-sidebar-header.append-bottom-default.w-100 + %a.gutter-toggle.float-right.d-block.d-sm-block.d-md-none.js-sidebar-wiki-toggle{ href: "#" } + = icon('angle-double-right') + + - git_access_url = wiki_path(@wiki, action: :git_access) + = link_to git_access_url, class: active_nav_link?(path: 'wikis#git_access') ? 'active' : '', data: { qa_selector: 'clone_repository_link' } do + = icon('cloud-download', class: 'append-right-5') + %span= _("Clone repository") + + .blocks-container + .block.block-first.w-100 + - if @sidebar_page + = render_wiki_content(@sidebar_page) + - else + %ul.wiki-pages + = render @sidebar_wiki_entries, context: 'sidebar' + .block.w-100 + - if @sidebar_limited + = link_to wiki_path(@wiki, action: :pages), class: 'btn btn-block' do + = s_("Wiki|View All Pages") diff --git a/app/views/shared/wikis/_sidebar_wiki_page.html.haml b/app/views/shared/wikis/_sidebar_wiki_page.html.haml new file mode 100644 index 00000000000..2573471f9f9 --- /dev/null +++ b/app/views/shared/wikis/_sidebar_wiki_page.html.haml @@ -0,0 +1,3 @@ +%li{ class: active_when(params[:id] == wiki_page.slug) } + = link_to wiki_page_path(@wiki, wiki_page) do + = wiki_page.human_title diff --git a/app/views/shared/wikis/_wiki_directory.html.haml b/app/views/shared/wikis/_wiki_directory.html.haml new file mode 100644 index 00000000000..0e5f32ed859 --- /dev/null +++ b/app/views/shared/wikis/_wiki_directory.html.haml @@ -0,0 +1,4 @@ +%li + = wiki_directory.slug + %ul + = render wiki_directory.pages, context: context diff --git a/app/views/shared/wikis/_wiki_page.html.haml b/app/views/shared/wikis/_wiki_page.html.haml new file mode 100644 index 00000000000..b27feac86cc --- /dev/null +++ b/app/views/shared/wikis/_wiki_page.html.haml @@ -0,0 +1 @@ += render "shared/wikis/#{context}_wiki_page", wiki_page: wiki_page diff --git a/app/views/shared/wikis/edit.html.haml b/app/views/shared/wikis/edit.html.haml new file mode 100644 index 00000000000..5bda8d85627 --- /dev/null +++ b/app/views/shared/wikis/edit.html.haml @@ -0,0 +1,31 @@ +- @content_class = "limit-container-width" unless fluid_layout +- add_to_breadcrumbs _("Wiki"), wiki_page_path(@wiki, @page) +- breadcrumb_title @page.persisted? ? _("Edit") : _("New") +- page_title @page.persisted? ? _("Edit") : _("New"), @page.human_title, _("Wiki") + += wiki_page_errors(@error) + +.wiki-page-header.top-area.has-sidebar-toggle.flex-column.flex-lg-row + %button.btn.btn-default.sidebar-toggle.js-sidebar-wiki-toggle{ role: "button", type: "button" } + = icon('angle-double-left') + + .nav-text + %h2.wiki-page-title + - if @page.persisted? + = link_to @page.human_title, wiki_page_path(@wiki, @page) + %span.light + · + = s_("Wiki|Edit Page") + - else + = s_("Wiki|Create New Page") + + .nav-controls.pb-md-3.pb-lg-0 + - if @page.persisted? + = link_to wiki_page_path(@wiki, @page, action: :history), class: "btn" do + = s_("Wiki|Page history") + - if can?(current_user, :admin_wiki, @wiki.container) + #delete-wiki-modal-wrapper{ data: { delete_wiki_url: wiki_page_path(@wiki, @page), page_title: @page.human_title } } + += render 'shared/wikis/form', uploads_path: wiki_attachment_upload_url + += render 'shared/wikis/sidebar' diff --git a/app/views/shared/wikis/empty.html.haml b/app/views/shared/wikis/empty.html.haml new file mode 100644 index 00000000000..62fa6e1907b --- /dev/null +++ b/app/views/shared/wikis/empty.html.haml @@ -0,0 +1,4 @@ +- page_title _("Wiki") +- @right_sidebar = false + += render 'shared/empty_states/wikis' diff --git a/app/views/shared/wikis/history.html.haml b/app/views/shared/wikis/history.html.haml new file mode 100644 index 00000000000..ec07082bd02 --- /dev/null +++ b/app/views/shared/wikis/history.html.haml @@ -0,0 +1,41 @@ +- page_title _("History"), @page.human_title, _("Wiki") + +.wiki-page-header.top-area.has-sidebar-toggle.flex-column.flex-lg-row + %button.btn.btn-default.sidebar-toggle.js-sidebar-wiki-toggle{ role: "button", type: "button" } + = icon('angle-double-left') + + .nav-text + %h2.wiki-page-title + = link_to @page.human_title, wiki_page_path(@wiki, @page) + %span.light + · + = _("History") + +.table-holder + %table.table + %thead + %tr + %th= s_("Wiki|Page version") + %th= _("Author") + %th= _("Commit Message") + %th= _("Last updated") + %th= _("Format") + %tbody + - @page_versions.each_with_index do |version, index| + - commit = version + %tr + %td + = link_to wiki_page_path(@wiki, @page, version_id: index == 0 ? nil : commit.id) do + = truncate_sha(commit.id) + %td + = commit.author_name + %td + = commit.message + %td + #{time_ago_with_tooltip(version.authored_date)} + %td + %strong + = version.format += paginate @page_versions, theme: 'gitlab' + += render 'shared/wikis/sidebar' diff --git a/app/views/shared/wikis/pages.html.haml b/app/views/shared/wikis/pages.html.haml new file mode 100644 index 00000000000..987c696cdfe --- /dev/null +++ b/app/views/shared/wikis/pages.html.haml @@ -0,0 +1,32 @@ +- add_to_breadcrumbs "Wiki", wiki_path(@wiki) +- breadcrumb_title s_("Wiki|Pages") +- page_title s_("Wiki|Pages"), _("Wiki") +- sort_title = wiki_sort_title(params[:sort]) + +.wiki-page-header.top-area.flex-column.flex-lg-row + + .nav-text.flex-fill + %h2.wiki-page-title + = s_("Wiki|Wiki Pages") + + .nav-controls.pb-md-3.pb-lg-0 + = link_to wiki_path(@wiki, action: :git_access), class: 'btn' do + = icon('cloud-download') + = _("Clone repository") + + .dropdown.inline.wiki-sort-dropdown + .btn-group{ role: 'group' } + .btn-group{ role: 'group' } + %button.dropdown-toggle{ type: 'button', data: { toggle: 'dropdown', display: 'static' }, class: 'btn btn-default' } + = sort_title + = icon('chevron-down') + %ul.dropdown-menu.dropdown-menu-right.dropdown-menu-selectable.dropdown-menu-sort + %li + = sortable_item(s_("Wiki|Title"), wiki_path(@wiki, action: :pages, sort: Wiki::TITLE_ORDER), sort_title) + = sortable_item(s_("Wiki|Created date"), wiki_path(@wiki, action: :pages, sort: Wiki::CREATED_AT_ORDER), sort_title) + = wiki_sort_controls(@wiki, params[:sort], params[:direction]) + +%ul.wiki-pages-list.content-list + = render @wiki_entries, context: 'pages' + += paginate @wiki_pages, theme: 'gitlab' diff --git a/app/views/shared/wikis/show.html.haml b/app/views/shared/wikis/show.html.haml new file mode 100644 index 00000000000..a4f3996e5de --- /dev/null +++ b/app/views/shared/wikis/show.html.haml @@ -0,0 +1,32 @@ +- @content_class = "limit-container-width" unless fluid_layout +- breadcrumb_title @page.human_title +- wiki_breadcrumb_dropdown_links(@page.slug) +- page_title @page.human_title, _("Wiki") +- add_to_breadcrumbs _("Wiki"), wiki_path(@wiki) + +.wiki-page-header.top-area.has-sidebar-toggle.flex-column.flex-lg-row + %button.btn.btn-default.sidebar-toggle.js-sidebar-wiki-toggle{ role: "button", type: "button" } + = icon('angle-double-left') + + .nav-text.flex-fill + %h2.wiki-page-title{ data: { qa_selector: 'wiki_page_title' } }= @page.human_title + %span.wiki-last-edit-by + - if @page.last_version + = (_("Last edited by %{name}") % { name: "<strong>#{@page.last_version.author_name}</strong>" }).html_safe + #{time_ago_with_tooltip(@page.last_version.authored_date)} + + .nav-controls.pb-md-3.pb-lg-0 + = render 'shared/wikis/main_links' + +- if @page.historical? + .warning_message + = s_("WikiHistoricalPage|This is an old version of this page.") + - most_recent_link = link_to s_("WikiHistoricalPage|most recent version"), wiki_page_path(@wiki, @page) + - history_link = link_to s_("WikiHistoricalPage|history"), wiki_page_path(@wiki, @page, action: :history) + = (s_("WikiHistoricalPage|You can view the %{most_recent_link} or browse the %{history_link}.") % { most_recent_link: most_recent_link, history_link: history_link }).html_safe + +.prepend-top-default.append-bottom-default + .md{ data: { qa_selector: 'wiki_page_content' } } + = render_wiki_content(@page) + += render 'shared/wikis/sidebar' |