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
pull/1/head
allo 19 years ago
parent 59b9540eb6
commit d2f34a2e94

@ -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()));
}
}
}

@ -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");

Loading…
Cancel
Save