summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorallo <allo@6c8d7289-2bf4-0310-a012-ef5d649a1542>2006-03-17 20:48:00 +0000
committerallo <allo@6c8d7289-2bf4-0310-a012-ef5d649a1542>2006-03-17 20:48:00 +0000
commitd2f34a2e94538c1f7ebcbb590ca8eea8d8213902 (patch)
tree8aabb554dea434859567a418ca66633f29bd2b0b
parent59b9540eb6c02b96a556d86d2d11d1bc6d422042 (diff)
skin in DATA/HTDOCS (works after upgrade, works when only DATA is writable).
preference of skinfiles: -style.css will be overwritten on every new SVN, if "DATA/SKINS/"+currentSkin+".css" exists. -DATA/SKINS will be overwritten with defaultskins from /skins so develop your skins in DATA/SKINS, and put them into skins for distribution. git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1913 6c8d7289-2bf4-0310-a012-ef5d649a1542
-rw-r--r--htroot/ConfigSkins_p.java15
-rw-r--r--skins/default.css (renamed from htroot/env/style.css)0
-rw-r--r--source/migration.java26
3 files changed, 34 insertions, 7 deletions
diff --git a/htroot/ConfigSkins_p.java b/htroot/ConfigSkins_p.java
index 0cfdfdbf5..7d15c8e4f 100644
--- a/htroot/ConfigSkins_p.java
+++ b/htroot/ConfigSkins_p.java
@@ -76,22 +76,23 @@ public class ConfigSkins_p {
}
}
- private static boolean changeSkin(serverSwitch env, String skinPath, String skin){
- File styleFile = new File(env.getRootPath(), "htroot/env/style.css");
+ private static boolean changeSkin(plasmaSwitchboard sb, String skinPath, String skin){
+ File htdocsDir = new File(sb.getRootPath(), sb.getConfig("htDocsPath", "DATA/HTDOCS")+"/env");
+ File styleFile = new File(htdocsDir, "style.css");
File skinFile = new File(skinPath, skin);
+ styleFile.getParentFile().mkdirs();
if(copyFile(skinFile, styleFile)){
- env.setConfig("currentSkin", skin.substring(0,skin.length()-4));
+ sb.setConfig("currentSkin", skin.substring(0,skin.length()-4));
return true;
}
return false;
}
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
- //listManager.switchboard = (plasmaSwitchboard) env;
serverObjects prop = new serverObjects();
plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
- String skinPath = new File(env.getRootPath(), env.getConfig("skinPath", "DATA/SKINS")).toString();
+ String skinPath = new File(env.getRootPath(), env.getConfig("skinsPath", "DATA/SKINS")).toString();
//Fallback
prop.put("currentskin", "");
@@ -112,7 +113,7 @@ public class ConfigSkins_p {
if (post != null){
//change skin
if(post.containsKey("use_button")){
- changeSkin(env, skinPath, (String)post.get("skin"));
+ changeSkin(switchboard, skinPath, (String)post.get("skin"));
//delete skin
}else if(post.containsKey("delete")){
@@ -144,7 +145,7 @@ public class ConfigSkins_p {
return prop;
}
if(post.containsKey("use_skin") && ((String)post.get("use_skin")).equals("on")){
- changeSkin(env, skinPath, url.substring(url.lastIndexOf("/"), url.length()));
+ changeSkin(switchboard, skinPath, url.substring(url.lastIndexOf("/"), url.length()));
}
}
}
diff --git a/htroot/env/style.css b/skins/default.css
index 4a19ba1a1..4a19ba1a1 100644
--- a/htroot/env/style.css
+++ b/skins/default.css
diff --git a/source/migration.java b/source/migration.java
index 0ce4c98ae..11bf707d6 100644
--- a/source/migration.java
+++ b/source/migration.java
@@ -65,9 +65,35 @@ public class migration {
migrateBookmarkTagsDB(sb);
}
serverLog.logInfo("MIGRATION", "Migrating from "+String.valueOf(fromRev)+ " to "+String.valueOf(toRev));
+ installSkin(sb);
migrate(sb);
}
}
+ public static void installSkin(plasmaSwitchboard sb){
+ String skin=sb.getConfig("currentSkin", "default");
+ if(skin.equals("")){
+ skin="default";
+ }
+ File skinsDir=new File(sb.getRootPath(), sb.getConfig("skinsPath", "DATA/SKINS"));
+ File skinFile=new File(skinsDir, skin+".css");
+ File htdocsPath=new File(sb.getRootPath(), sb.getConfig("htdocsPath", "DATA/HTDOCS")+"/env");
+ File styleFile=new File(htdocsPath, "style.css");
+ if(!skinFile.exists()){
+ if(styleFile.exists()){
+ serverLog.logInfo("MIGRATION", "Skin "+skin+" not found. Keeping old skin.");
+ }else{
+ serverLog.logSevere("MIGRATION", "Skin "+skin+" and no existing Skin found.");
+ }
+ }else{
+ try {
+ styleFile.getParentFile().mkdirs();
+ serverFileUtils.copy(skinFile, styleFile);
+ serverLog.logInfo("MIGRATION", "copied new Skinfile");
+ } catch (IOException e) {
+ serverLog.logSevere("MIGRATION", "Cannot copy skinfile.");
+ }
+ }
+ }
public static void migrateBookmarkTagsDB(plasmaSwitchboard sb){
sb.bookmarksDB.close();
File tagsDBFile=new File(sb.workPath, "bookmarkTags.db");