This question about Missing functionality: Answered
Add Raw View Button at Top of Page
I want a "Raw VIew" button at the top of each page, along with "Edit" and "Attach".
I've managed to find the (almost) right template definition and move it into position, but the Look & Feel doesn't match.
I've got this (in view.pattern.tmpl)
%TMPL:DEF{"top:toolbarbuttons"}%%TMPL:P{"raw_link_short"}%%TMPL:P{"activatable_edit_or_create"}%%TMPL:P{"activatable_attach"}%%TMPL:P{context="SubscribePluginEnabled" then="activatable_subscribe"}%%TMPL:END%%{
and this on the page:
I've done a "View Source" but am currently stumped about what I need to add/remove/change to make the "Raw" button look like the other two buttons.
I'm sure this is something so smiple [_sic_] that I'm overlooking it.
--
VickiBrown - 26 Mar 2014
Pretty sure you're missing a CSS class or two. I'd poke around in the JS debugger, and poke values until it looks right.
--
CrawfordCurrie - 27 Mar 2014
OK. I poked at the CSS. The class that changes the button format is
foswikiRequiresChangePermission
which is completely inappropriate. A requirement of change permission should
not set the look and feel of a button element this way.
Switching over to a bug report,
Tasks/Item12827.
If there is a class that duplicates the Look&Feel of
foswikiRequiresChangePermission
, please let me know. I tried to look through
pub/System/PatternSkinTheme/jquery-ui.css
and the lack of formatting made that impossible.
Current workaround is to use class
foswikiRequiresChangePermission
, but setting that on a Raw View button is Just Wrong™.
--
VickiBrown - 28 Mar 2014
Vicki,
foswikiRequiresChangePermission is actually undefined. It can be set by CSS to disable ALL elements that should disappear when a user is not allowed to edit. You can review
EnableWikiEditingOfSystemTopics for a bit more on how this works.
As far as the button styling, it's done in foswiki.pattern.tmpl, I think the topicactionbuttonsrow template definition. I think it's the #patternTopBarButtons css
--
GeorgeClark - 28 Mar 2014
Okay.... These changes to the templates work. The Raw view is styled correctly, and it fixes the Subscribe button as well.
Note that it's not good practice to actually modify these templates. Future upgrades will be very difficult. It's better to copy them to a different skin name and override the skin.
diff --git a/PatternSkin/templates/view.pattern.tmpl b/PatternSkin/templates/view.pattern.tmpl
index 865926b..4494e2d 100644
--- a/PatternSkin/templates/view.pattern.tmpl
+++ b/PatternSkin/templates/view.pattern.tmpl
@@ -23,7 +23,7 @@
---------------------------------------------------
}%%TMPL:DEF{"top"}%<div class="patternTop"><span class="patternHomePath foswikiLeft">%TMPL:P{"breadcrumb"}%</span><span class="patternToolBar foswikiRight">%TMPL:P{"top:toolbarbuttons"}%</span><div class="foswikiClear"></div></div>%TMPL:END%
-%TMPL:DEF{"top:toolbarbuttons"}%%TMPL:P{"activatable_edit_or_create"}%%TMPL:P{"activatable_attach"}%%TMPL:P{context="SubscribePluginEnabled" then="activatable_subscribe"}%%TMPL:END%%{
+%TMPL:DEF{"top:toolbarbuttons"}%%TMPL:P{"raw_link_short"}%%TMPL:P{"activatable_edit_or_create"}%%TMPL:P{"activatable_attach"}%%TMPL:P{context="SubscribePluginEnabled" then="activatable_subscribe"}%%TMPL:END%%{
---------------------------------------------------
}%%TMPL:DEF{"breadcrumb:separator"}%<span class='foswikiSeparator'>></span>%TMPL:END%
diff --git a/core/templates/viewtopicactionbuttons.tmpl b/core/templates/viewtopicactionbuttons.tmpl
index b382004..24834cd 100644
--- a/core/templates/viewtopicactionbuttons.tmpl
+++ b/core/templates/viewtopicactionbuttons.tmpl
@@ -13,7 +13,7 @@
%TMPL:DEF{"attach_link"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURLPATH{"attach"}%/%BASEWEB%/%BASETOPIC%' rel='nofollow' %MAKETEXT{"title='Attach an image or document to this topic' accesskey='a'>&Attach"}%</a></span>%TMPL:END%
-%TMPL:DEF{"subscribe_link"}%<span>%SUBSCRIBE{format="<a href='$url' rel='nofollow' %MAKETEXT{"title='Subscribe to this topic' accesskey='s'>&Subscribe"}%</a>" formatunsubscribe="<a href='$url' rel='nofollow' %MAKETEXT{"title='Unsubscribe from this topic' accesskey='s'>Un&subscribe"}%</a>"}%</span>%TMPL:END%
+%TMPL:DEF{"subscribe_link"}%<span class="foswikiRequiresChangePermission">%SUBSCRIBE{format="<a href='$url' rel='nofollow' %MAKETEXT{"title='Subscribe to this topic' accesskey='s'>&Subscribe"}%</a>" formatunsubscribe="<a href='$url' rel='nofollow' %MAKETEXT{"title='Unsubscribe from this topic' accesskey='s'>Un&subscribe"}%</a>"}%</span>%TMPL:END%
%TMPL:DEF{"more_link"}%<span><a href='%SCRIPTURLPATH{"view"}%/%BASEWEB%/%BASETOPIC%?template=more&maxrev=%MAXREV%&currrev=%CURRREV%' rel='nofollow' %MAKETEXT{"title='Delete or rename this topic; set parent topic; view and compare revisions' accesskey='m'>&More topic actions"}%</a></span>%TMPL:END%
@@ -37,6 +37,7 @@
%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%
+%TMPL:DEF{"raw_link_short"}%<a href='%SCRIPTURLPATH{"view"}%/%BASEWEB%/%BASETOPIC%?raw=on%REVARG%' rel='nofollow' %MAKETEXT{"title='View without formatting' accesskey='v'>&View (raw)"}%</a>%TMPL:END%
It's the extra <span> in the original raw_link button that was loosing the styling.
--
GeorgeClark - 29 Mar 2014
"Note that it's not good practice to actually modify these templates. Future upgrades will be very difficult. "
Future upgrades are actually slightly less difficult than if I make a local "cover". In the one case, I need to remember to edit; in the other, I need to remember to import the cover and compare it to the template I'm overriding. Depending on changes to the dist template, that comparison may be difficult.
--
VickiBrown - 29 Mar 2014