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

WIP: Add redirection control panel #2256

Open
wants to merge 2 commits into
base: master
from
File filter...
Filter file types
Jump to file or symbol
Failed to load files and symbols.
+862 −0
Diff settings

Always

Just for now

Copy path View file
@@ -30,6 +30,11 @@ New Features:
- Mockup update.
[thet]

- PLIP 1486: Merge Products.RedirectionTool into core
Allow users to manage redirects on their site and aliases to content.
See https://github.com/plone/Products.CMFPlone/issues/1486
[staeff]

Bug Fixes:

- Improved isURLInPortal according to PloneHotfix20171128.
@@ -291,4 +291,19 @@
permission="cmf.ManagePortal"
/>

<browser:page
name="redirection-controlpanel"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
class=".redirects.RedirectsControlPanel"
permission="cmf.ManagePortal"
/>

<browser:page
name="manage-aliases"
for="Products.CMFCore.interfaces.IContentish"
class=".redirects.RedirectsView"
permission="cmf.ModifyPortalContent"
allowed_attributes="redirects view_url errors"
/>

</configure>
@@ -0,0 +1,174 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
xml:lang="en" lang="en"
metal:use-macro="context/prefs_main_template/macros/master"
i18n:domain="plone">

<body>
<div metal:fill-slot="prefs_configlet_main">
<dl
tal:condition="view/errors"
class="portalMessage error">
<dt>Error</dt>
<dd>
<p i18n:translate="error_bulk_upload">
No aliases were added. Please correct these errors in your CSV file and try again:

This comment has been minimized.

@djay

djay Jan 11, 2019

Member

Please change the use of the word Alias. It's not obvious to users what this means. Users think of alternative urls or short urls as the words they use in my experience. Redirection might also be possible but it could be confusing with other forms of redirection

</p>
<table
style="text-align: left; vertical-align: top"
border="0"
cellpadding="2"
cellspacing="0">
<tr tal:repeat="error view/errors"
style="vertical-align: top">
<td nowrap="nowrap">
<tal:block i18n:translate="label_bulk_upload_line">
Line
</tal:block>
${error/line_number}
<tal:block i18n:translate="label_bulk_upload_line_suffix">
:
</tal:block>
</td>
<td>
${error/line}
</td>
<td>
${error/message}
</td>
</tr>
</table>
</dd>
</dl>

<h1 i18n:translate="heading_add_aliases">
Manage aliases
</h1>

<form
action="${view/view_url}"
method="post">
<fieldset>
<legend i18n:translate="add_alias">
Add a new alias
</legend>

<label for="redirection">Alias Path</label>
<input
type="text"
name="redirection">

<label for="target_path">Target Path</label>
<input
type="text"
name="target_path">

<div class="formControls">
<input class="context"
type="submit"
value="Add"
name="form.button.Add"
i18n:attributes="value" />
</div>

</fieldset>
</form>


<form
action="${view/view_url}"
method="post"
enctype="multipart/form-data">
<fieldset>
<legend i18n:translate="legend_bulk_upload">
Bulk-upload aliases
</legend>

<p i18n:translate="description_bulk_upload">
Add many aliases at once by uploading a CSV file. The first column should be the path to
redirect from; the second, the path to redirect to. Both paths must be Plone-site-relative,
starting with a slash (/).
</p>
<p>
<tal:block i18n:translate="example_caption_bulk_upload">Example:</tal:block><br />
<code i18n:translate="example_bulk_upload">
/old-home-page.asp,/front-page<br />
/people/JoeT,/Users/joe-thurston
</code>
</p>

<input
type="file"
name="file" />

<div class="formControls">
<input
class="context"
type="submit"
value="Upload"
name="form.button.Upload"
i18n:attributes="value"
/>
</div>

</fieldset>
</form>

<form
action="${view/view_url}#manage-existing-aliases"
method="post"
id="manage-existing-aliases">
<fieldset
tal:define="batch view/redirects">
<legend i18n:translate="legend_all_existing_aliases">
All existing aliases for this site
</legend>

<label for="filter-existing-aliases-q" i18n:translate="">Filter by prefix</label>
<input
type="text"
name="q"
value=""
id="filter-existing-aliases-q"
tal:attributes="value python:request.form.get('q', '/')"/>
<div class="formControls">
<input
class="context"
type="submit"
value="Filter"
name="form.button.filter"
i18n:attributes="value" />
</div>

<tal:redirects repeat="redirect batch">
<div>
<label>
<input
type="checkbox"
class="noborder"
name="redirects:tuple"
value="${redirect/redirect}" />
${redirect/path} &rarr; ${redirect/redirect-to}
</label>
</div>
</tal:redirects>

<div tal:condition="python:batch.numpages > 1"
tal:replace="structure view/batching">
</div>

<div class="formControls">
<input class="context"
type="submit"
value="Remove"
name="form.button.Remove"
i18n:attributes="value" />
</div>

</fieldset>
</form>
</div>
</body>
</html>
@@ -0,0 +1,130 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en-US" lang="en-US"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
metal:use-macro="here/main_template/macros/master"
i18n:domain="plone">

<body>
<div
metal:fill-slot="main"
tal:define="context_state context/@@plone_context_state">
<h1
class="documentFirstHeading"
i18n:translate="heading_add_aliases">
Manage aliases
</h1>

<dl
class="portalMessage info"
tal:condition="context_state/is_default_page">
<dt i18n:translate="">
Info
</dt>
<dd i18n:translate="help_sharing_page_default_page">
You are managing the aliases of a default view in a container.
To manage them for the entire container,
<a
i18n:name="go_here"
i18n:translate="help_aliases_go_here"
tal:define="folder context_state/folder"
tal:attributes="href string:${folder/absolute_url}/@@manage-aliases">
go here
</a>.
</dd>
</dl>

<p i18n:translate="description_adding_aliases">
Using this form, you can manage aliases for an item. This
is an easy way to make an item available under two different URLs.
</p>

<form
action="${view/view_url}"
method="post">
<fieldset>
<legend i18n:translate="legend_existing_aliases">
Existing aliases for this item
</legend>

<div class="field"
tal:define="error options/errors/redirection|nothing;
redirection request/title | nothing;"
tal:attributes="class python:error and 'field error' or 'field'">
<label
for="title"
i18n:translate="label_alias">
Alias
</label>

<span
class="fieldRequired"
title="Required"
i18n:attributes="title"
i18n:translate="label_required">
(Required)
</span>

<div tal:content="error">
Validation error output
</div>

<div class="formHelp" i18n:translate="help_alias">
Enter the absolute path where the alias should exist. The path must start with '/'.
</div>

<input
type="text"
name="redirection"
value="#"
size="40"
tal:attributes="value request/redirection | nothing;"/>
</div>
<div class="formControls">
<input
class="context"
type="submit"
value="Add"
name="form.button.Add"
i18n:attributes="value" />
</div>

</fieldset>
</form>

<form
action="${view/view_url}"
method="post">
<fieldset>
<legend i18n:translate="legend_existing_aliases">
Existing aliases for this item
</legend>

<tal:redirects repeat="redirect view/redirects">
<div>
<label>
<input
type="checkbox"
class="noborder"
name="redirects:tuple"
value="${redirect/redirect}" />
${redirect/path}
</label>
</div>
</tal:redirects>

<div class="formControls">
<input
class="context"
type="submit"
value="Remove"
name="form.button.Remove"
i18n:attributes="value" />
</div>

</fieldset>
</form>
</div>
</body>
</html>
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.