Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Redmine Wikiのページツリー構造をドラッグ&ドロップで編集できるプラグインを作りました

Redmine Wikiのページツリー構造をドラッグ&ドロップで編集できるプラグインを作りました

shigeru. nakajima

November 18, 2017
Tweet

More Decks by shigeru. nakajima

Other Decks in Technology

Transcript

  1. redmine_wiki_page_tree_hook_list ener.rb View Hook view_layouts_base_sidebarΛఆٛ def view_layouts_base_sidebar(context = {}) return

    unless context[:controller] params = context[:controller].params return unless params[:controller] == 'wiki' pages = load_pages(context[:request].params[:project_id]) pages_by_parent_id = pages.group_by(&:parent_id) content_tag(:div, class: 'page-tree') do concat content_tag(:h2, 'ϖʔδπϦʔϏϡʔ', class: 'page-tree__title') concat render_page_hierarchy(pages_by_parent_id, nil, :timestamp => true) end end
  2. init.rb require_dependency 'redmine_wiki_page_tree_hook_listener' Redmine::Plugin.register :redmine_wiki_page_tree do name 'Redmine Wiki Page

    Tree Plugin' author 'Shigeru Nakajima' description 'Redmine plugin to show the page tree view at the sidebar.' version '0.0.1' url 'https://github.com/ledsun/redmine_wiki_page_tree' author_url 'https://github.com/ledsun' end
  3. ΠϯσϯτΛ੔ܗ CSSΛ௥Ճ #sidebar .page-tree { margin-left: -12px; padding-top: 10px; }

    #sidebar .page-tree__title { margin-left: 12px; } #sidebar .page-tree__list { margin: 0 12px; } #sidebar .page-tree__list__node--leaf { list-style-type: disc; margin-left: 13px; }
  4. assetͷ௥Ճ redmine_wiki_page_tree_hook_listener.rb def view_layouts_base_html_head(context) return unless context[:controller] params = context[:controller].params

    return unless params[:controller] == 'wiki' tags = [] tags << stylesheet_link_tag('sidebar__page-tree', :plugin => 'redmine_wiki_page_tree') tags << javascript_include_tag('sidebar__page-tree', :plugin => 'redmine_wiki_page_tree') tags.join("\n") end