You are here: Foswiki>Tasks Web>Item12103 (05 Jul 2015, GeorgeClark)Edit Attach

Item12103: Simplify CSS, remove foswikiRequiresChangePermission span, add it to a class on the link.

pencil
Priority: Normal
Current State: Closed
Released In: 2.0.0
Target Release: major
Applies To: Engine
Component: FoswikiCSS, FoswikiTemplates
Branches: master
Reported By: ArthurClemens
Waiting For:
Last Change By: GeorgeClark
Action links are wrapped inside a span foswikiRequiresChangePermission.

This leads to this kind of CSS:
> a,
> .foswikiRequiresChangePermission a {
...
}

Better is to set the class on the link:
<a class='foswikiRequiresChangePermission'></a>

-- ArthurClemens - 29 Sep 2012

Michael, I have a fix for this stashed away. I seem to recall talking to you about this, and you had some concerns? Here are my stashed changes:
commit d0de7537f0887a89a70eae683cd5575618791a4d
Merge: 017dd35 3d4507a
Author: George Clark <geonwiki@fenachrone.com>
Date:   Fri Jan 9 10:38:16 2015 -0500

    On master: foswikiHasChange changes Item12103

diff --combined FamFamFamContrib/templates/view.famfamfam.tmpl
index 5f91976,5f91976..7001fe4
--- a/FamFamFamContrib/templates/view.famfamfam.tmpl
+++ b/FamFamFamContrib/templates/view.famfamfam.tmpl
@@@ -1,12 -1,12 +1,12 @@@
  %TMPL:INCLUDE{"view"}%
  %TMPL:DEF{"top:toolbarbutton_edit"}%<span>
--      <a href="%SCRIPTURL{"edit"}%/%WEB%/%TOPIC%?t=%GMTIME{"$epoch"}%" title="%MAKETEXT{"Edit this topic text (e)"}%">
--              <img alt="%MAKETEXT{"Edit this topic text (e)"}%" src="%PUBURL%/%SYSTEMWEB%/FamFamFamSilkIcons/pencil.png" width="16" height="16" />
++      <a class='foswikiRequiresChangePermission' href='%SCRIPTURL{"edit"}%/%WEB%/%TOPIC%?t=%GMTIME{"$epoch"}%' title='%MAKETEXT{"Edit this topic text (e)"}%'>
++              <img alt='%MAKETEXT{"Edit this topic text (e)"}%' src='%PUBURL%/%SYSTEMWEB%/FamFamFamSilkIcons/pencil.png' width='16' height='16' />
        </a></span>%TMPL:END%
  
  %TMPL:DEF{"top:toolbarbutton_attach"}%<span>
--      <a href="%SCRIPTURL{"attach"}%/%WEB%/%TOPIC%" title="%MAKETEXT{"Attach an image or document to this topic; manage existing attachments (a)"}%">
--              <img alt="%MAKETEXT{"Attach an image or document to this topic; manage existing attachments (a)"}%" src="%PUBURL%/%SYSTEMWEB%/FamFamFamSilkIcons/attach.png" width="16" height="16" />
++      <a class='foswikiRequiresChangePermission' href='%SCRIPTURL{"attach"}%/%WEB%/%TOPIC%' title='%MAKETEXT{"Attach an image or document to this topic; manage existing attachments (a)"}%'>
++              <img alt='%MAKETEXT{"Attach an image or document to this topic; manage existing attachments (a)"}%' src='%PUBURL%/%SYSTEMWEB%/FamFamFamSilkIcons/attach.png' width='16' height='16' />
        </a></span>%TMPL:END%
  
  %TMPL:DEF{"top:toolbarbutton_subscribe"}%<span>
@@@ -17,28 -17,28 +17,28 @@@
      </a>"}%</span>%TMPL:END%
  
  %TMPL:DEF{"top:toolbarbutton_rdiff"}%<span>
--      <a href="%SCRIPTURL{"rdiff"}%/%WEB%/%TOPIC%?type=history" title="%MAKETEXT{"View sequential topic history"}%">
--              <img alt="%MAKETEXT{"View sequential topic history"}%" src="%PUBURL%/%SYSTEMWEB%/FamFamFamSilkIcons/page_white_stack.png" width="16" height="16" />
++      <a href='%SCRIPTURL{"rdiff"}%/%WEB%/%TOPIC%?type=history' title='%MAKETEXT{"View sequential topic history"}%'>
++              <img alt='%MAKETEXT{"View sequential topic history"}%' src='%PUBURL%/%SYSTEMWEB%/FamFamFamSilkIcons/page_white_stack.png' width='16' height='16' />
        </a></span>%TMPL:END%
  
  %TMPL:DEF{"top:toolbarbutton_raw"}%<span>
--      <a href="%SCRIPTURL{"view"}%/%WEB%/%TOPIC%?raw=on&rev=%REVINFO{"$rev"}%" title="%MAKETEXT{"View without formatting (v)"}%">
--              <img alt="%MAKETEXT{"View without formatting (v)"}%" src="%PUBURL%/%SYSTEMWEB%/FamFamFamSilkIcons/text_align_left.png" width="16" height="16" />
++      <a href='%SCRIPTURL{"view"}%/%WEB%/%TOPIC%?raw=on&rev=%REVINFO{"$rev"}%' title='%MAKETEXT{"View without formatting (v)"}%'>
++              <img alt='%MAKETEXT{"View without formatting (v)"}%' src='%PUBURL%/%SYSTEMWEB%/FamFamFamSilkIcons/text_align_left.png' width='16' height='16' />
        </a></span>%TMPL:END%
  
  %TMPL:DEF{"top:toolbarbutton_create"}%<span>
--      <a href="%SCRIPTURL{"view"}%/%WEB%/WebCreateNewTopic?topicparent=%TOPIC%" title="%MAKETEXT{"Create new topic"}%">
--              <img alt="%MAKETEXT{"Create new topic"}%" src="%PUBURL%/%SYSTEMWEB%/FamFamFamSilkIcons/page_white_add.png" width="16" height="16" />
++      <a class='foswikiRequiresChangePermission' href='%SCRIPTURL{"view"}%/%WEB%/WebCreateNewTopic?topicparent=%TOPIC%' title='%MAKETEXT{"Create new topic"}%'>
++              <img alt='%MAKETEXT{"Create new topic"}%' src='%PUBURL%/%SYSTEMWEB%/FamFamFamSilkIcons/page_white_add.png' width='16' height='16' />
        </a></span>%TMPL:END%
  
  %TMPL:DEF{"top:toolbarbutton_print"}%<span>
--      <a href="%SCRIPTURL{"view"}%/%WEB%/%TOPIC%?cover=print;%QUERYSTRING%" title="%MAKETEXT{"Printable version of this topic (p)"}%">
--              <img alt="%MAKETEXT{"Printable version of this topic (p)"}%" src="%PUBURL%/%SYSTEMWEB%/FamFamFamSilkIcons/printer.png" width="16" height="16" />
++      <a href='%SCRIPTURL{"view"}%/%WEB%/%TOPIC%?cover=print;%QUERYSTRING%' title='%MAKETEXT{"Printable version of this topic (p)"}%'>
++              <img alt='%MAKETEXT{"Printable version of this topic (p)"}%' src='%PUBURL%/%SYSTEMWEB%/FamFamFamSilkIcons/printer.png' width='16' height='16' />
        </a></span>%TMPL:END%
  
  %TMPL:DEF{"top:toolbarbutton_more"}%<span>
--        <a href="%SCRIPTURL{"oops"}%/%WEB%/%TOPIC%?template=more&maxrev=%REVINFO{"$rev"}%&currrev=%REVINFO{"$rev"}%" title="%MAKETEXT{"More: delete or rename this topic; set parent topic; view and compare revisions (m)"}%">
--                <img alt="%MAKETEXT{"More: delete or rename this topic; set parent topic; view and compare revisions (m)"}%" src="%PUBURL%/%SYSTEMWEB%/FamFamFamSilkIcons/wrench.png" width="16" height="16" />
++        <a href='%SCRIPTURL{"oops"/%/%WEB%/%TOPIC%?template=more&maxrev=%REVINFO{"$rev"}%&currrev=%REVINFO{"$rev"}%' title='%MAKETEXT{"More: delete or rename this topic; set parent topic; view and compare revisions (m)"}%'>
++                <img alt='%MAKETEXT{"More: delete or rename this topic; set parent topic; view and compare revisions (m)"}%' src='%PUBURL%/%SYSTEMWEB%/FamFamFamSilkIcons/wrench.png' width='16' height='16' />
        </a></span>%TMPL:END%
  
  %TMPL:DEF{"top:toolbarbuttons_inner"}%                %TMPL:P{
@@@ -62,6 -62,6 +62,6 @@@
  %TMPL:DEF{"authenticatedClass"}% foswikiAuthenticated%TMPL:END%
  %TMPL:DEF{"unauthenticatedClass"}% foswikiUnauthenticated%TMPL:END%
  
--%TMPL:DEF{"top:toolbarbuttons"}%<span class="foswikiToolBar foswikiRight%TMPL:P{context="authenticated" then="authenticatedClass" else="unauthenticatedClass"}%">
++%TMPL:DEF{"top:toolbarbuttons"}%<span class='foswikiToolBar foswikiRight%TMPL:P{context="authenticated" then="authenticatedClass" else="unauthenticatedClass"}%'>
  %TMPL:P{"top:toolbarbuttons_inner"}%
                </span>%TMPL:END% 
diff --combined PatternSkin/pub/System/PatternSkinTheme/style_src.css
index d6edda8,d6edda8..cfbc40b
--- a/PatternSkin/pub/System/PatternSkinTheme/style_src.css
+++ b/PatternSkin/pub/System/PatternSkinTheme/style_src.css
@@@ -1351,10 -1351,10 +1351,6 @@@ pre ul:last-child
  .foswikiButtonSmall.foswikiActive,
  .foswikiButtonLarge.foswikiActive,
  .foswikiButtonMini.foswikiActive,
--.foswikiButton > .foswikiRequiresChangePermission a:hover,
--.foswikiButtonSmall > .foswikiRequiresChangePermission a:hover,
--.foswikiButtonLarge > .foswikiRequiresChangePermission a:hover,
--.foswikiButtonMini > .foswikiRequiresChangePermission a:hover {
    color: #484848;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
    background-color: #e6e6e6;
@@@ -1382,10 -1382,10 +1378,6 @@@
  .foswikiButtonSmall.foswikiActive .foswikiIcon,
  .foswikiButtonLarge.foswikiActive .foswikiIcon,
  .foswikiButtonMini.foswikiActive .foswikiIcon,
--.foswikiButton > .foswikiRequiresChangePermission a:hover .foswikiIcon,
--.foswikiButtonSmall > .foswikiRequiresChangePermission a:hover .foswikiIcon,
--.foswikiButtonLarge > .foswikiRequiresChangePermission a:hover .foswikiIcon,
--.foswikiButtonMini > .foswikiRequiresChangePermission a:hover .foswikiIcon {
    color: #484848;
  }
  .foswikiButton:hover .foswikiCaret,
@@@ -1396,10 -1396,10 +1388,6 @@@
  .foswikiButtonSmall.foswikiActive .foswikiCaret,
  .foswikiButtonLarge.foswikiActive .foswikiCaret,
  .foswikiButtonMini.foswikiActive .foswikiCaret,
--.foswikiButton > .foswikiRequiresChangePermission a:hover .foswikiCaret,
--.foswikiButtonSmall > .foswikiRequiresChangePermission a:hover .foswikiCaret,
--.foswikiButtonLarge > .foswikiRequiresChangePermission a:hover .foswikiCaret,
--.foswikiButtonMini > .foswikiRequiresChangePermission a:hover .foswikiCaret {
    border-top-color: rgba(72, 72, 72, 0.4);
  }
  .foswikiButton .foswikiAccessKey,
diff --combined PatternSkin/templates/view.pattern.tmpl
index b24bfc8,b24bfc8..ccd8478
--- a/PatternSkin/templates/view.pattern.tmpl
+++ b/PatternSkin/templates/view.pattern.tmpl
@@@ -4,7 -4,7 +4,7 @@@
  %TMPL:INCLUDE{"viewsidebar"}%
  %TMPL:DEF{"logo"}%%TMPL:END%%{
  ---------------------------------------------------
--}%%TMPL:DEF{"bodyclassname"}%patternViewPage%IF{"defined raw" then=" patternRawViewPage"}%%TMPL:END%%{
++}%%TMPL:DEF{"bodyclassname"}%patternViewPage%IF{"'%TOPIC%' allows 'CHANGE'" then=" foswikiHasChangePermission" else=" foswikiHasNoChangePermission"}%%IF{"context authenticated" then=" foswikiLoggedIn" else=" foswikiGuest"}%%IF{"defined raw" then=" patternRawViewPage"}%%TMPL:END%%{
  ---------------------------------------------------
  }%%TMPL:DEF{"script:skintemplate"}%%IF{"defined raw" then="$percntTMPL:P{$quotscript:skintemplate:viewraw$quot}$percnt"}%%TMPL:END%%{
  ---------------------------------------------------
diff --combined core/pub/System/SkinTemplates/base_src.css
index ec2e9d6,ec2e9d6..a111fc9
--- a/core/pub/System/SkinTemplates/base_src.css
+++ b/core/pub/System/SkinTemplates/base_src.css
@@@ -13,6 -13,6 +13,10 @@@
  .foswikiMakeVisible {
        display:inline;
  }
++
++.foswikiHasNoChangePermission.foswikiLoggedIn .foswikiRequiresChangePermission { display: none; } */
++
++a.foswikiMakeVisible,
  p.foswikiMakeVisible,
  h1.foswikiMakeVisible,
  h2.foswikiMakeVisible,
diff --combined core/templates/viewtopicactionbuttons.tmpl
index 3e82b26,3e82b26..dc09119
--- a/core/templates/viewtopicactionbuttons.tmpl
+++ b/core/templates/viewtopicactionbuttons.tmpl
@@@ -2,17 -2,17 +2,17 @@@
  
  %TMPL:DEF{nowysiwyg}%;nowysiwyg=1%TMPL:END%
  
--%TMPL:DEF{"create_topic_link"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURL{"edit"}%/%BASEWEB%/%BASETOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%%TMPL:P{context="TinyMCEPluginEnabled" else="nowysiwyg"}%' rel='nofollow' %MAKETEXT{"title='Create new topic' accesskey='c'>&Create"}%</a></span>%TMPL:END%
++%TMPL:DEF{"create_topic_link"}%<a class='foswikiRequiresChangePermission' href='%SCRIPTURL{"edit"}%/%BASEWEB%/%BASETOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%%TMPL:P{context="TinyMCEPluginEnabled" else="nowysiwyg"}%' rel='nofollow' %MAKETEXT{"title='Create new topic' accesskey='c'>&Create"}%</a>%TMPL:END%
  
  
--%TMPL:DEF{"edit_topic_link"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURL{"edit"}%/%BASEWEB%/%BASETOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%%TMPL:P{context="TinyMCEPluginEnabled" else="nowysiwyg"}%' rel='nofollow' %IF{"context footer_text" then="%MAKETEXT{"title='Edit this topic text' accesskey='e'>&Edit"}%" else="%MAKETEXT{"title='Edit this topic text' >Edit"}%" }% </a></span>%TMPL:END%
++%TMPL:DEF{"edit_topic_link"}%<a class='foswikiRequiresChangePermission' href='%SCRIPTURL{"edit"}%/%BASEWEB%/%BASETOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%%TMPL:P{context="TinyMCEPluginEnabled" else="nowysiwyg"}%' rel='nofollow' %IF{"context footer_text" then="%MAKETEXT{"title='Edit this topic text' accesskey='e'>&Edit"}%" else="%MAKETEXT{"title='Edit this topic text' >Edit"}%" }% </a>%TMPL:END%
  
--%TMPL:DEF{"raw_edit_link"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURL{"edit"}%/%BASEWEB%/%BASETOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%;nowysiwyg=1' rel='nofollow' %MAKETEXT{"title='Edit Wiki text' accesskey='w'>Edit &wiki text"}%</a></span>%TMPL:END%
++%TMPL:DEF{"raw_edit_link"}%<a class='foswikiRequiresChangePermission' href='%SCRIPTURL{"edit"}%/%BASEWEB%/%BASETOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%;nowysiwyg=1' rel='nofollow' %MAKETEXT{"title='Edit Wiki text' accesskey='w'>Edit &wiki text"}%</a>%TMPL:END%
  
  %TMPL:DEF{"view_topic_link"}%<span><a href='%SCRIPTURL{"view"}%/%BASEWEB%/%BASETOPIC%' rel='nofollow' %MAKETEXT{"title='View topic' accesskey='v'>&View topic"}%</a></span>%TMPL:END%
  
  
--%TMPL:DEF{"attach_link"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURLPATH{"attach"}%/%BASEWEB%/%BASETOPIC%' rel='nofollow' %IF{"context footer_text" then="%MAKETEXT{"title='Attach an image or document to this topic' accesskey='a'>&Attach"}%" else="%MAKETEXT{"title='Attach an image or document to this topic'>Attach"}%" }%</a></span>%TMPL:END%
++%TMPL:DEF{"attach_link"}%<a class='foswikiRequiresChangePermission' href='%SCRIPTURLPATH{"attach"}%/%BASEWEB%/%BASETOPIC%' rel='nofollow' %IF{"context footer_text" then="%MAKETEXT{"title='Attach an image or document to this topic' accesskey='a'>&Attach"}%" else="%MAKETEXT{"title='Attach an image or document to this topic'>Attach"}%" }%</a>%TMPL:END%
  
  %TMPL:DEF{"subscribe_link"}%<span>%SUBSCRIBE{format="<a href='$url' class='subscribe_link' data-subscribe='$restparams' rel='nofollow' %MAKETEXT{"title='Subscribe to this topic' accesskey='s'>&Subscribe"}%</a>" formatunsubscribe="<a href='$url' class='subscribe_link' data-subscribe='$restparams' rel='nofollow' %MAKETEXT{"title='Unsubscribe from this topic' accesskey='s'>Un&subscribe"}%</a>"}%</span>%TMPL:END%
  
@@@ -32,9 -32,9 +32,9 @@@
  %TMPL:DEF{"backlinks_link"}%<span><a href='%SCRIPTURLPATH{"view"}%/%BASEWEB%/%BASETOPIC%?template=backlinksweb' rel='nofollow' %MAKETEXT{"title='Search the [_1] Web for topics that link to here' accesskey='b'>&Backlinks" args="<nop>%BASEWEB%"}%</a></span>%TMPL:END%
  
  
--%TMPL:DEF{"history_rdiff_link"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURLPATH{"rdiff"}%/%BASEWEB%/%BASETOPIC%?type=history' rel='nofollow' %MAKETEXT{"title='View complete topic history' accesskey='h'>&History"}%</a></span>%TMPL:END%
++%TMPL:DEF{"history_rdiff_link"}%<a class='foswikiRequiresChangePermission' href='%SCRIPTURLPATH{"rdiff"}%/%BASEWEB%/%BASETOPIC%?type=history' rel='nofollow' %MAKETEXT{"title='View complete topic history' accesskey='h'>&History"}%</a>%TMPL:END%
  
--%TMPL:DEF{"history_history_link"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURLPATH{"oops"}%/%BASEWEB%/%BASETOPIC%?template=oopshistory' rel='nofollow' %MAKETEXT{"title='View complete topic history' accesskey='h'>&History"}%</a></span>%TMPL:END%
++%TMPL:DEF{"history_history_link"}%<a class='foswikiRequiresChangePermission' href='%SCRIPTURLPATH{"oops"}%/%BASEWEB%/%BASETOPIC%?template=oopshistory' rel='nofollow' %MAKETEXT{"title='View complete topic history' accesskey='h'>&History"}%</a>%TMPL:END%
  
  
  %TMPL:DEF{"raw_link"}%<span><a href='%SCRIPTURLPATH{"view"}%/%BASEWEB%/%BASETOPIC%?raw=on%REVARG%' rel='nofollow' %MAKETEXT{"title='View without formatting' accesskey='v'>&View wiki text"}%</a></span>%TMPL:END%

-- GeorgeClark - 11 Feb 2015

Hi George, the changes look good.

Though I am not sure hiding a foswikiRequiresChangePermission is a good thing to do for a couple of reasons:

  1. Users not authenticated yet might want to click on an edit link to trigger a login loop just before entering the editor.
  2. Better don't render any link to an action at all that you don't have clearance for yet. Bots will pick them up anyway no matter what css display settings it has got.
  3. This only affects actions such as edit, save, diff, subscribe, attach and the like but not lins to topics or unknown WikiWords.
  4. Whether or not access to diff requires change permissions depends on configuration settings, so you can't globally hide them independently.

I am not 100% behind (1) but I still mention it as it has been a typical argument that came up in this discussion before.

From what I see the above patch is fine minus the display:none setting in the css. That might need further rethinking.

-- MichaelDaum - 12 Feb 2015

+1 on all your points. I didn't intend to leave this active by default. It's mainly cleanup of an optional feature that isn't well documented. As it does simplify some of the CSS even when not enabled, I'll check it in, and also try to add some documentation to the CSS Cookbook

-- GeorgeClark - 12 Feb 2015
 

ItemTemplate edit

Summary Simplify CSS, remove foswikiRequiresChangePermission span, add it to a class on the link.
ReportedBy ArthurClemens
Codebase trunk
SVN Range
AppliesTo Engine
Component FoswikiCSS, FoswikiTemplates
Priority Normal
CurrentState Closed
WaitingFor
Checkins distro:add5167ca563 distro:71973ab3f743
TargetRelease major
ReleasedIn 2.0.0
CheckinsOnBranches master
trunkCheckins
masterCheckins distro:add5167ca563 distro:71973ab3f743
ItemBranchCheckins
Release01x01Checkins
Topic revision: r9 - 05 Jul 2015, GeorgeClark - This page was cached on 30 Jun 2016 - 15:57.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License