-
-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speed improvements for /admin/pages/ #921
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,12 @@ class << self | |
|
||
alias_method :rootpage, :root | ||
|
||
# Make sure Page.root does not hit the database all the time. | ||
# | ||
def root | ||
RequestStore.store[:alchemy_page_root] ||= super | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a great idea! |
||
end | ||
|
||
# Used to store the current page previewed in the edit page template. | ||
# | ||
def current_preview=(page) | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<%- tree = pages_tree_from(root) -%> | ||
<%- tree.each_with_index do |(page, level), i| -%> | ||
<%- page_has_children = tree[i + 1] && tree[i + 1][1] > level -%> | ||
<li id="page_<%= page.id %>" class="page_level_<%= "#{level} #{page.page_layout}" %>" data-slug="<%= page.slug %>" data-restricted="<%= page.restricted? %>" data-visible="<%= page.visible? %>" data-external="<%= page.redirects_to_external? %>"> | ||
<div class="sitemap_page<%= page.locked ? ' locked' : '' %>" name="<%= page.name %>"> | ||
<div class="sitemap_left_images"> | ||
<% sitemap_folder_link(page) unless level == 1 || !page_has_children || @sorting %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. <%= sitemap_folder_link(page), ..
without loud erb the folder link isn't visible, but maybe it's intended by you, because the folding doesn't work anymore, because of missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep. Folding is broken at the moment. Also in the client side approach. Since we're going for the client side approach, I didn't bother fixing that just yet in this pull request. |
||
<%- if page.layout_description.blank? -%> | ||
<span class="inline warning icon" title="<%= _t(:page_layout_description_missing) %>"></span> | ||
<%- else -%> | ||
<div class="page icon <%= @sorting && level > 1 ? 'handle' : nil %>"></div> | ||
<%- end -%> | ||
</div> | ||
<div class="sitemap_right_tools"> | ||
<%- unless @sorting -%> | ||
<%- if can?(:info, page) -%> | ||
<%= link_to_dialog( | ||
render_icon('info'), | ||
alchemy.info_admin_page_path(page), | ||
{ | ||
title: _t(:page_infos), | ||
size: '520x290' | ||
}, | ||
{ | ||
title: _t(:page_infos), | ||
class: 'sitemap_tool' | ||
} | ||
) %> | ||
<%- end -%> | ||
<%- if can?(:configure, page) -%> | ||
<%= link_to_dialog( | ||
render_icon('configure_page'), | ||
alchemy.configure_admin_page_path(page), | ||
{ | ||
title: _t(:edit_page_properties), | ||
size: page.redirects_to_external? ? '450x330' : '450x720' | ||
}, | ||
title: _t(:edit_page_properties), | ||
class: 'sitemap_tool' | ||
) -%> | ||
<%- end -%> | ||
<span class="sitemap_sitetools"> | ||
<%- if can?(:copy, page) -%> | ||
<%= link_to( | ||
render_icon("copy_page"), | ||
alchemy.insert_admin_clipboard_path( | ||
remarkable_type: page.class.name.demodulize.underscore.pluralize, | ||
remarkable_id: page.id | ||
), | ||
remote: true, | ||
method: 'post', | ||
title: _t(:copy_page), | ||
class: 'sitemap_tool' | ||
) %> | ||
<%- end -%> | ||
<%- if can?(:destroy, page) -%> | ||
<%= link_to_confirm_dialog( | ||
render_icon('delete_page'), | ||
_t(:confirm_to_delete_page), | ||
url_for( | ||
controller: 'pages', | ||
action: 'destroy', | ||
id: page.id | ||
), | ||
{ | ||
title: _t(:delete_page), | ||
class: 'sitemap_tool' | ||
} | ||
) -%> | ||
<%- end -%> | ||
<%- if can?(:create, Alchemy::Page) -%> | ||
<%= link_to_dialog( | ||
render_icon('add_page'), | ||
alchemy.new_admin_page_path(parent_id: page.id), | ||
{ | ||
title: _t(:create_page), | ||
size: '340x165', | ||
overflow: true | ||
}, | ||
title: _t(:create_page), | ||
class: 'sitemap_tool' | ||
) -%> | ||
<%- end -%> | ||
</span> | ||
<%- end -%> | ||
</div> | ||
<div class="page_infos" id="page_<%= page.id %>_infos"> | ||
<span class="page_status <%= page.public ? 'public' : 'not_public' %>" title="<%= page.status_title(:public) %>"></span> | ||
<span class="page_status <%= page.visible ? 'visible' : 'not_visible' %>" title="<%= page.status_title(:visible) %>"></span> | ||
<span class="page_status <%= page.restricted ? 'restricted' : 'not_restricted' %>" title="<%= page.status_title(:restricted) %>"></span> | ||
</div> | ||
<div class="sitemap_sitename"> | ||
<%- if page.redirects_to_external? -%> | ||
<span class="sitemap_pagename_link inactive"><%= page.name %></span> | ||
<span class="redirect_url" title="<%= h page.urlname %>"> | ||
» <%= _t('Redirects to') %>: | ||
<%= h page.external_urlname %> | ||
</span> | ||
<%- else -%> | ||
<%= link_to_unless( | ||
@sorting, | ||
page.name, | ||
alchemy.edit_admin_page_path(page), | ||
title: _t(:edit_page), | ||
class: "sitemap_pagename_link" | ||
) { content_tag('span', page.name, class: "sitemap_pagename_link") } -%> | ||
<%- end -%> | ||
</div> | ||
</div> | ||
<%- if @sorting || (page_has_children && !page.folded?(current_alchemy_user)) -%> | ||
<ul id="page_<%= page.id %>_children" class="level_<%= level %>_children"> | ||
<%- elsif !tree[i + 1] || tree[i + 1][1] < level -%> | ||
<%- (level - (tree[i + 1] ? tree[i + 1][1] : 1)).times do -%></li></ul><%- end -%> | ||
<%- else -%> | ||
</li> | ||
<%- end -%> | ||
<%- end -%> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not necessary, since Alchemy is Ruby >= 2 and utf-8 is default encoding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was added automatically by Emacs. Feel free to remove it, although in my opinion it's not a bad idea to keep it there. Some editors don't detect file encoding automatically.