Author: gmazza
Date: Tue Aug 26 17:30:28 2014
New Revision: 1620669
URL: http://svn.apache.org/r1620669
Log:
Simplifications to ThemeEdit.jsp
Modified:
roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogTheme.java
roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
roller/trunk/app/src/main/resources/ApplicationResources.properties
roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/ThemeEdit.jsp
roller/trunk/app/src/main/webapp/roller-ui/styles/roller.css
Modified:
roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogTheme.java
URL:
http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogTheme.java?rev=1620669&r1=1620668&r2=1620669&view=diff
==============================================================================
---
roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogTheme.java
(original)
+++
roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogTheme.java
Tue Aug 26 17:30:28 2014
@@ -31,7 +31,7 @@ public abstract class WeblogTheme implem
// this is the name that will be used to identify a user customized theme
public static final String CUSTOM = "custom";
-
+
protected Weblog weblog = null;
Modified:
roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
URL:
http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java?rev=1620669&r1=1620668&r2=1620669&view=diff
==============================================================================
---
roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
(original)
+++
roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
Tue Aug 26 17:30:28 2014
@@ -54,14 +54,11 @@ public class ThemeEdit extends UIAction
// type of theme desired, either 'shared' or 'custom'
private String themeType = null;
- // the chosen shared theme id
+ // the currently selected theme, shared or custom
private String themeId = null;
- // import the selected theme to the action weblog
- private boolean importTheme = false;
-
- // the chosen import theme id
- private String importThemeId = null;
+ // a potentially new selected theme
+ private String selectedThemeId = null;
// Do we have a custom stylesheet already
private boolean customStylesheet = false;
@@ -84,9 +81,10 @@ public class ThemeEdit extends UIAction
// set theme to current value
if (WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme())) {
setThemeId(null);
+ setSelectedThemeId(null);
} else {
setThemeId(getActionWeblog().getTheme().getId());
- setImportThemeId(getActionWeblog().getTheme().getId());
+ setSelectedThemeId(getThemeId());
}
// See if we have a custom style sheet from a custom theme.
@@ -123,74 +121,57 @@ public class ThemeEdit extends UIAction
// Are we dealing with a custom theme scenario?
if (WeblogTheme.CUSTOM.equals(getThemeType())) {
- // only continue if custom themes are allowed
- if (WebloggerRuntimeConfig
- .getBooleanProperty("themes.customtheme.allowed")) {
+ // do theme import if necessary
+ SharedTheme t;
- // do theme import if necessary
- SharedTheme t = null;
+ try {
+ ThemeManager themeMgr = WebloggerFactory.getWeblogger()
+ .getThemeManager();
+ t = themeMgr.getTheme(getSelectedThemeId());
+ if (!StringUtils.isEmpty(getSelectedThemeId())) {
+ themeMgr.importTheme(getActionWeblog(), t);
+ }
+ } catch (Exception re) {
+ log.error("Error customizing theme for weblog - "
+ + getActionWeblog().getHandle(), re);
+ addError("generic.error.check.logs");
+ return execute();
+ }
+ if (!hasActionErrors()) {
try {
- ThemeManager themeMgr = WebloggerFactory.getWeblogger()
- .getThemeManager();
- t = themeMgr.getTheme(getImportThemeId());
- if (isImportTheme()
- && !StringUtils.isEmpty(getImportThemeId())) {
- themeMgr.importTheme(getActionWeblog(), t);
- }
- } catch (Exception re) {
- log.error("Error customizing theme for weblog - "
- + getActionWeblog().getHandle(), re);
- addError("Error importing theme - check Roller logs");
- }
+ weblog.setEditorTheme(WeblogTheme.CUSTOM);
+ log.debug("Saving custom theme for weblog "
+ + weblog.getHandle());
- if (!hasActionErrors()) {
- try {
- weblog.setEditorTheme(WeblogTheme.CUSTOM);
- log.debug("Saving custom theme for weblog "
- + weblog.getHandle());
-
- // save updated weblog and flush
- WebloggerFactory.getWeblogger().getWeblogManager()
- .saveWeblog(weblog);
- WebloggerFactory.getWeblogger().flush();
-
- // make sure to flush the page cache so ppl can see the
- // change
- CacheManager.invalidate(weblog);
-
- addMessage("themeEditor.setTheme.success",
WeblogTheme.CUSTOM);
- if (isImportTheme() && t != null) {
- addMessage("Successfully copied templates from
theme - "
- + t.getName());
- }
+ // save updated weblog and flush
+ WebloggerFactory.getWeblogger().getWeblogManager()
+ .saveWeblog(weblog);
+ WebloggerFactory.getWeblogger().flush();
- // reset import theme options
- setImportTheme(false);
- setImportThemeId(null);
-
- } catch (WebloggerException re) {
- log.error("Error saving weblog - "
- + getActionWeblog().getHandle(), re);
- addError("generic.error.check.logs");
- }
+ // make sure to flush the page cache so ppl can see the
change
+ CacheManager.invalidate(weblog);
+
+ addMessage("themeEditor.setCustomTheme.success",
t.getName());
+ addMessage("themeEditor.setCustomTheme.instructions");
+
+ } catch (WebloggerException re) {
+ log.error("Error saving weblog - "
+ + getActionWeblog().getHandle(), re);
+ addError("generic.error.check.logs");
}
- } else {
- addError("themeEditor.customTheme.disallowed");
}
-
- // we are dealing with a shared theme scenario
} else if ("shared".equals(getThemeType())) {
// make sure theme is valid and enabled
Theme newTheme = null;
- if (getThemeId() == null) {
+ if (selectedThemeId == null) {
addError("No theme specified");
} else {
try {
ThemeManager themeMgr = WebloggerFactory.getWeblogger()
.getThemeManager();
- newTheme = themeMgr.getTheme(getThemeId());
+ newTheme = themeMgr.getTheme(selectedThemeId);
if (!newTheme.isEnabled()) {
addError("Theme not enabled");
@@ -212,7 +193,7 @@ public class ThemeEdit extends UIAction
// Remove old style sheet
if (!WeblogTheme.CUSTOM.equals(originalTheme)
- && !originalTheme.equals(getThemeId())
+ && !originalTheme.equals(selectedThemeId)
&& getActionWeblog().getTheme().getStylesheet() !=
null) {
WeblogTemplate stylesheet = mgr.getTemplateByLink(
@@ -225,9 +206,9 @@ public class ThemeEdit extends UIAction
}
}
- weblog.setEditorTheme(getThemeId());
+ weblog.setEditorTheme(selectedThemeId);
- log.debug("Saving theme " + getThemeId() + " for weblog "
+ log.debug("Saving theme " + selectedThemeId + " for weblog
"
+ weblog.getHandle());
// save updated weblog and flush
@@ -235,12 +216,11 @@ public class ThemeEdit extends UIAction
.saveWeblog(weblog);
WebloggerFactory.getWeblogger().flush();
- // make sure to flush the page cache so ppl can see the
- // change
+ // make sure to flush the page cache so ppl can see the
change
CacheManager.invalidate(weblog);
// Theme set to..
- if (!originalTheme.equals(getThemeId())) {
+ if (!originalTheme.equals(selectedThemeId)) {
addMessage("themeEditor.setTheme.success",
newTheme.getName());
}
@@ -302,20 +282,12 @@ public class ThemeEdit extends UIAction
this.themeId = theme;
}
- public boolean isImportTheme() {
- return importTheme;
- }
-
- public void setImportTheme(boolean importTheme) {
- this.importTheme = importTheme;
- }
-
- public String getImportThemeId() {
- return importThemeId;
+ public String getSelectedThemeId() {
+ return selectedThemeId;
}
- public void setImportThemeId(String importThemeId) {
- this.importThemeId = importThemeId;
+ public void setSelectedThemeId(String importThemeId) {
+ this.selectedThemeId = importThemeId;
}
/**
@@ -327,14 +299,4 @@ public class ThemeEdit extends UIAction
return customStylesheet;
}
- /**
- * Sets the custom stylesheet.
- *
- * @param customStylesheet
- * the custom stylesheet
- */
- public void setCustomStylesheet(boolean customStylesheet) {
- this.customStylesheet = customStylesheet;
- }
-
}
Modified: roller/trunk/app/src/main/resources/ApplicationResources.properties
URL:
http://svn.apache.org/viewvc/roller/trunk/app/src/main/resources/ApplicationResources.properties?rev=1620669&r1=1620668&r2=1620669&view=diff
==============================================================================
--- roller/trunk/app/src/main/resources/ApplicationResources.properties
(original)
+++ roller/trunk/app/src/main/resources/ApplicationResources.properties Tue Aug
26 17:30:28 2014
@@ -1276,27 +1276,19 @@ themeEditor.yourCustomStylesheet=using <
themeEditor.yourThemeStyleSheet=using the <em>Shared Theme</em> default
stylesheet.
themeEditor.selectTheme=Select a new shared theme for your blog
-themeEditor.templatesLink=Start editing your blog templates.
-themeEditor.templatesDescription=Now that you are using a custom theme the \
-design of your blog is defined entirely by you using a series of templates. \
-You can modify your templates as much as you like and if you ever decide you \
-want to start over you can do so by copying one of the existing themes.
-
themeEditor.preview=Preview Theme
themeEditor.save=Update Theme
themeEditor.previewDescription=Prior to changing your theme, the preview
option below \
can be used to see how your blog''s main front page would look with the new
theme.
-themeEditor.import=I want to copy the templates from an existing theme into my
weblog.
-themeEditor.importWarning=WARNING: this operation may overwrite some of your \
-existing templates.
+themeEditor.importWarning=WARNING: Updating your custom theme may overwrite
some of your existing templates.
themeEditor.importRequired=Since this is the first time you are going to try a
\
-custom theme you must copy the templates from an existing theme. \
-Please select the theme you would like to use as a starting point for your
customizations.
+custom theme you must first copy templates from an existing theme.
-themeEditor.setTheme.success=Successfully set theme to - {0}
-themeEditor.customTheme.disallowed=Sorry, custom themes are not allowed
+themeEditor.setTheme.success=Theme set to {0}
+themeEditor.setCustomTheme.success=Theme set to custom, using templates from
{0} theme
+themeEditor.setCustomTheme.instructions=Use the Stylesheet and Templates tabs
above to edit your custom theme.
# ----------------------------------------------------------------------
Uploads
Modified: roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/ThemeEdit.jsp
URL:
http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/ThemeEdit.jsp?rev=1620669&r1=1620668&r2=1620669&view=diff
==============================================================================
--- roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/ThemeEdit.jsp
(original)
+++ roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/ThemeEdit.jsp Tue Aug
26 17:30:28 2014
@@ -90,110 +90,58 @@ function updateThemeChooser(selected) {
</s:else>
</s:if>
<s:else>
- <s:text name="themeEditor.selectTheme" />
+ <s:text name="themeEditor.selectTheme" />:
</s:else>
</p>
- <p>
- <s:select id="sharedSelector" name="themeId" list="themes"
- listKey="id" listValue="name" size="1"
- onchange="previewImage($('#sharedPreviewImg'),
$('#sThemeDescription'), this[selectedIndex].value)"/>
- </p>
- <p id="sThemeDescription"></p>
- <p>
- <img id="sharedPreviewImg" src="" />
- <!-- initialize preview image at page load -->
- <script>
- <s:if test="customTheme">
- previewImage($('#sharedPreviewImg'),
$('#sThemeDescription'), '<s:property value="themes[0].id"/>');
- </s:if>
- <s:else>
- previewImage($('#sharedPreviewImg'),
$('#sThemeDescription'), '<s:property value="themeId"/>');
- </s:else>
- </script>
- </p>
- <p>
- <s:text name="themeEditor.previewDescription" />
- </p>
-
- <div class="control">
- <span style="padding-left:7px">
- <input type="button" name="themePreview"
- value="<s:text name='themeEditor.preview' />"
-
onclick="fullPreview($('#sharedSelector').get(0))" />
-
- <s:submit value="%{getText('themeEditor.save')}" />
- </span>
- </div>
-
</div>
<div id="customOptioner" class="optioner" style="display:none;">
-
<s:if test="firstCustomization">
<p>
- <s:hidden name="importTheme" value="true" />
- <span class="warning"><s:text
name="themeEditor.importRequired" /></span>
+ <s:text name="themeEditor.importRequired" />
</p>
</s:if>
-
<s:else>
- <s:if test="customTheme">
- <p>
- <s:url var="templatesUrl" action="templates">
- <s:param name="weblog" value="%{actionWeblog.handle}"
/>
- </s:url>
- » <s:a href="%{templatesUrl}"><s:text
name="themeEditor.templatesLink" /></s:a><br/>
- <s:text name="themeEditor.templatesDescription" />
- </p>
- </s:if>
-
<p>
- <s:checkbox name="importTheme"
onclick="$('#themeImport').toggle();" />
- <s:text name="themeEditor.import" />
+ <span class="warning"><s:text name="themeEditor.importWarning"
/></span>
</p>
</s:else>
+ </div>
- <div id="themeImport" style="display:none;">
+ <div id="themeOptioner" class="optioner">
+ <p>
+ <s:select id="themeSelector" name="selectedThemeId" list="themes"
+ listKey="id" listValue="name" size="1"
+ onchange="previewImage($('#themeThumbnail'),
$('#themeDescription'), this[selectedIndex].value)"/>
+ </p>
+
+ <p id="themeDescription"></p>
+ <p>
+ <img id="themeThumbnail" src="" />
+ <!-- initialize preview image at page load -->
+ <script>
<s:if test="customTheme">
- <p>
- <span class="warning"><s:text
name="themeEditor.importWarning" /></span>
- </p>
+ previewImage($('#themeThumbnail'), $('#themeDescription'),
'<s:property value="themes[0].id"/>');
</s:if>
+ <s:else>
+ previewImage($('#themeThumbnail'), $('#themeDescription'),
'<s:property value="themeId"/>');
+ </s:else>
+ </script>
+ </p>
+ <p>
+ <s:text name="themeEditor.previewDescription" />
+ </p>
+ </div>
- <p>
- <s:select id="customSelector" name="importThemeId"
list="themes"
- listKey="id" listValue="name" size="1"
- onchange="previewImage($('#customPreviewImg'),
$('#cThemeDescription'), this[selectedIndex].value)"/>
- </p>
- <p id="cThemeDescription"></p>
- <p>
- <img id="customPreviewImg" src="" />
- <!-- initialize preview image at page load -->
- <script>
- <s:if test="customTheme">
- previewImage($('#customPreviewImg'),
$('#cThemeDescription'), '<s:property value="themes[0].id"/>');
- </s:if>
- <s:else>
- previewImage($('#customPreviewImg'),
$('#cThemeDescription'), '<s:property value="themeId"/>');
- </s:else>
- </script>
- </p>
- <p>
- <s:text name="themeEditor.previewDescription" />
- </p>
- </div>
-
- <div class="control">
- <span style="padding-left:7px">
- <input type="button" name="themePreview"
- value="<s:text name='themeEditor.preview' />"
-
onclick="fullPreview($('#customSelector').get(0))" />
-
- <s:submit value="%{getText('themeEditor.save')}" />
- </span>
- </div>
+ <div class="control">
+ <span style="padding-left:7px">
+ <input type="button" name="themePreview"
+ value="<s:text name='themeEditor.preview' />"
+ onclick="fullPreview($('#themeSelector').get(0))"
/>
+ <s:submit value="%{getText('themeEditor.save')}" />
+ </span>
</div>
</s:form>
@@ -202,9 +150,6 @@ function updateThemeChooser(selected) {
<script>
<s:if test="customTheme">
updateThemeChooser($('#customRadio'));
- <s:if test="firstCustomization">
- $('#themeImport').show();
- </s:if>
</s:if>
<s:else>
updateThemeChooser($('#sharedRadio'));
Modified: roller/trunk/app/src/main/webapp/roller-ui/styles/roller.css
URL:
http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/roller-ui/styles/roller.css?rev=1620669&r1=1620668&r2=1620669&view=diff
==============================================================================
--- roller/trunk/app/src/main/webapp/roller-ui/styles/roller.css (original)
+++ roller/trunk/app/src/main/webapp/roller-ui/styles/roller.css Tue Aug 26
17:30:28 2014
@@ -762,11 +762,11 @@ div.selectedChooser {
border: 1px solid #008000;
}
-.chooser h2 {
+div.chooser h2 {
letter-spacing: 0.0em;
}
-.optioner {
+div.optioner {
margin: 0px 30px 30px 30px;
}