Skip to content
Browse files

More server settings.

  • Loading branch information...
1 parent ddd032a commit 1e7824a774e1ea45af54749474ef100b24060c9d @a-fung committed Oct 20, 2012
View
3 source/aspnetserver/Handler/AdminSettingsGetRequestHandler.cs
@@ -26,6 +26,9 @@ public override void HandleRequest(string jsonString, AjaxBase ajax)
response.zip = Settings.UseZip;
response.rar = Settings.UseRar;
response.pdf = Settings.UsePdf;
+ response.preprocessCount = Settings.MangaPagePreProcessCount;
+ response.preprocessDelay = Settings.MangaPagePreProcessDelay;
+ response.cacheLimit = Settings.MangaCacheSizeLimit;
ajax.ReturnJson(response);
}
View
15 source/aspnetserver/Handler/AdminSettingsSetRequestHandler.cs
@@ -28,6 +28,21 @@ public override void HandleRequest(string jsonString, AjaxBase ajax)
Settings.UseRar = request.rar;
Settings.UsePdf = request.pdf;
+ if (request.preprocessCount >= 0 && request.preprocessCount < 100)
+ {
+ Settings.MangaPagePreProcessCount = request.preprocessCount;
+ }
+
+ if (request.preprocessDelay >= 0 && request.preprocessDelay < 100000)
+ {
+ Settings.MangaPagePreProcessDelay = request.preprocessDelay;
+ }
+
+ if (request.cacheLimit >= 50 && request.cacheLimit < 100000)
+ {
+ Settings.MangaCacheSizeLimit = request.cacheLimit;
+ }
+
ajax.ReturnJson(new JsonResponse());
}
}
View
2 source/aspnetserver/Manga.cs
@@ -854,7 +854,7 @@ public static void CacheLimit()
files.Sort((x, y) => (int)Math.Round((y.LastWriteTimeUtc - x.LastWriteTimeUtc).TotalSeconds));
long totalSize = 0;
- long sizeLimit = 209715200L; // 200 MB
+ long sizeLimit = 1048576L * Settings.MangaCacheSizeLimit; // 1048576 = 1MB
foreach (FileInfo file in files)
{
if (totalSize > sizeLimit || (totalSize += file.Length) > sizeLimit)
View
36 source/aspnetserver/Settings.cs
@@ -151,6 +151,42 @@ public static int LastAutoAddProcessTime
}
}
+ public static int MangaPagePreProcessCount
+ {
+ get
+ {
+ return int.Parse(GetSettings()["mangapage_preprocess_count"]);
+ }
+ set
+ {
+ SetSetting("mangapage_preprocess_count", value.ToString());
+ }
+ }
+
+ public static int MangaPagePreProcessDelay
+ {
+ get
+ {
+ return int.Parse(GetSettings()["mangapage_preprocess_delay"]);
+ }
+ set
+ {
+ SetSetting("mangapage_preprocess_delay", value.ToString());
+ }
+ }
+
+ public static int MangaCacheSizeLimit
+ {
+ get
+ {
+ return int.Parse(GetSettings()["mangacache_sizelimit"]);
+ }
+ set
+ {
+ SetSetting("mangacache_sizelimit", value.ToString());
+ }
+ }
+
private static bool? _sevenZipConfigOk = null;
private static bool SevenZipConfigOk
View
4 source/aspnetserver/ThreadHelper.cs
@@ -86,15 +86,17 @@ private static void MangaPreprocessFiles(object[] parameters)
{
int page = (int)parameters[1];
- for (int i = 1; i <= 5; i++)
+ for (int i = 1; i <= Settings.MangaPagePreProcessCount; i++)
{
if (page + i >= 0 && page + i < manga.NumberOfPages)
{
+ Thread.Sleep(Settings.MangaPagePreProcessDelay);
manga.GetPage(page + i, (int)parameters[2], (int)parameters[3], 0);
}
if (page - i >= 0 && page - i < manga.NumberOfPages)
{
+ Thread.Sleep(Settings.MangaPagePreProcessDelay);
manga.GetPage(page - i, (int)parameters[2], (int)parameters[3], 0);
}
}
View
4 source/aspnetserver/lang/en-us.html
@@ -173,3 +173,7 @@
<p id="Loading">Loading...</p>
<p id="NoItem">No Item</p>
<p id="GuestNotAllowed">This may indicate that no guest is allow to access anything. Please try to login as a user.</p>
+<p id="PreprocessCount">Pre-process Count</p>
+<p id="PreprocessDelay">Pre-process Delay</p>
+<p id="CacheLimit">Cache Limit</p>
+<p id="Millisecond">ms</p>
View
4 source/aspnetserver/lang/zh-hk.html
@@ -173,3 +173,7 @@
<p id="Loading">載入中...</p>
<p id="NoItem">沒有項目</p>
<p id="GuestNotAllowed">可能是因為不允許客人訪問,請嘗試登入。</p>
+<p id="PreprocessCount">預處理頁數</p>
+<p id="PreprocessDelay">預處理延遲</p>
+<p id="CacheLimit">緩存限額</p>
+<p id="Millisecond">毫秒</p>
View
24 source/aspnetserver/template/admin.html
@@ -327,6 +327,30 @@ <h3 class="msg msg-Settings"></h3>
<input type="checkbox" id="admin-settings-pdf" /></label>
</div>
</div>
+ <div class="control-group">
+ <label class="msg msg-PreprocessCount control-label" for="admin-settings-preprocess-count"></label>
+ <div class="controls">
+ <input type="number" id="admin-settings-preprocess-count" class="input-small" maxlength="2" min="0" max="99">
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="msg msg-PreprocessDelay control-label" for="admin-settings-preprocess-delay"></label>
+ <div class="controls">
+ <div class="input-append">
+ <input type="number" id="admin-settings-preprocess-delay" class="input-small" maxlength="5" min="0" max="99999">
+ <span class="msg msg-Millisecond add-on"></span>
+ </div>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="msg msg-CacheLimit control-label" for="admin-settings-cachelimit"></label>
+ <div class="controls">
+ <div class="input-append">
+ <input type="number" id="admin-settings-cachelimit" class="input-small" maxlength="5" min="50" max="99999">
+ <span class="msg msg-MegaBytes add-on"></span>
+ </div>
+ </div>
+ </div>
</div>
<div class="modal-footer">
<input class="val val-Apply btn btn-primary" id="admin-settings-submit" type="submit" />
View
3 source/aspnetserverinstall/Handler/InstallRequestHandler.cs
@@ -76,6 +76,9 @@ public override void HandleRequest(string jsonString, AjaxBase ajax)
Settings.UsePdf = request.pdf;
Settings.AllowGuest = true;
Settings.LastAutoAddProcessTime = 0;
+ Settings.MangaPagePreProcessCount = 5;
+ Settings.MangaPagePreProcessDelay = 300;
+ Settings.MangaCacheSizeLimit = 200;
// Delete Install files
string[] filesToDelete =
View
3 source/csharpcommon/AdminSettingsGetResponse.cs
@@ -12,5 +12,8 @@ public class AdminSettingsGetResponse : JsonResponse
public bool zip;
public bool rar;
public bool pdf;
+ public int preprocessCount;
+ public int preprocessDelay;
+ public int cacheLimit;
}
}
View
3 source/csharpcommon/AdminSettingsSetRequest.cs
@@ -12,5 +12,8 @@ public class AdminSettingsSetRequest : JsonRequest
public bool zip;
public bool rar;
public bool pdf;
+ public int preprocessCount;
+ public int preprocessDelay;
+ public int cacheLimit;
}
}
View
3 source/haxe/afung/mangaWeb3/common/AdminSettingsGetResponse.hx
@@ -11,4 +11,7 @@ class AdminSettingsGetResponse extends JsonResponse
public var zip:Bool;
public var rar:Bool;
public var pdf:Bool;
+ public var preprocessCount:Int;
+ public var preprocessDelay:Int;
+ public var cacheLimit:Int;
}
View
3 source/haxe/afung/mangaWeb3/common/AdminSettingsSetRequest.hx
@@ -11,4 +11,7 @@ class AdminSettingsSetRequest extends JsonRequest
public var zip:Bool;
public var rar:Bool;
public var pdf:Bool;
+ public var preprocessCount:Int;
+ public var preprocessDelay:Int;
+ public var cacheLimit:Int;
}
View
4 source/haxe/afung/mangaWeb3/server/Manga.hx
@@ -725,7 +725,7 @@ class Manga
{
if (!FileSystem.exists(outputPath))
{
- var lockFile:Dynamic;
+ var lockFile:Dynamic = null;
try
{
lockFile = untyped __call__("@fopen", lockPath, "x");
@@ -826,7 +826,7 @@ class Manga
});
var totalSize:Int = 0;
- var sizeLimit:Int = 209715200; // 200 MB
+ var sizeLimit:Int = 1048576 * Settings.MangaCacheSizeLimit; // 1048576 = 1MB
for (i in 0...files.length)
{
var fileStat:FileStat = files[i][1];
View
39 source/haxe/afung/mangaWeb3/server/Settings.hx
@@ -123,4 +123,43 @@ class Settings
SetSetting("last_autoadd_time", Std.string(value));
return value;
}
+
+ public static var MangaPagePreProcessCount(get_MangaPagePreProcessCount, set_MangaPagePreProcessCount):Int;
+
+ private static function get_MangaPagePreProcessCount():Int
+ {
+ return Std.parseInt(GetSettings().get("mangapage_preprocess_count"));
+ }
+
+ private static function set_MangaPagePreProcessCount(value:Int):Int
+ {
+ SetSetting("mangapage_preprocess_count", Std.string(value));
+ return value;
+ }
+
+ public static var MangaPagePreProcessDelay(get_MangaPagePreProcessDelay, set_MangaPagePreProcessDelay):Int;
+
+ private static function get_MangaPagePreProcessDelay():Int
+ {
+ return Std.parseInt(GetSettings().get("mangapage_preprocess_delay"));
+ }
+
+ private static function set_MangaPagePreProcessDelay(value:Int):Int
+ {
+ SetSetting("mangapage_preprocess_delay", Std.string(value));
+ return value;
+ }
+
+ public static var MangaCacheSizeLimit(get_MangaCacheSizeLimit, set_MangaCacheSizeLimit):Int;
+
+ private static function get_MangaCacheSizeLimit():Int
+ {
+ return Std.parseInt(GetSettings().get("mangacache_sizelimit"));
+ }
+
+ private static function set_MangaCacheSizeLimit(value:Int):Int
+ {
+ SetSetting("mangacache_sizelimit", Std.string(value));
+ return value;
+ }
}
View
4 source/haxe/afung/mangaWeb3/server/ThreadHelper.hx
@@ -91,15 +91,17 @@ class ThreadHelper
{
var page:Int = parameters[1];
- for (i in 1...6)
+ for (i in 1...(1 + Settings.MangaPagePreProcessCount))
{
if (page + i >= 0 && page + i < manga.NumberOfPages)
{
+ Sys.sleep(Settings.MangaPagePreProcessDelay / 1000);
manga.GetPage(page + i, parameters[2], parameters[3], 0);
}
if (page - i >= 0 && page - i < manga.NumberOfPages)
{
+ Sys.sleep(Settings.MangaPagePreProcessDelay / 1000);
manga.GetPage(page - i, parameters[2], parameters[3], 0);
}
}
View
4 source/haxe/afung/mangaWeb3/server/handler/AdminSettingsGetRequestHandler.hx
@@ -2,6 +2,7 @@ package afung.mangaWeb3.server.handler;
import afung.mangaWeb3.common.AdminSettingsGetRequest;
import afung.mangaWeb3.common.AdminSettingsGetResponse;
+import afung.mangaWeb3.server.Settings;
/**
* ...
@@ -28,6 +29,9 @@ class AdminSettingsGetRequestHandler extends HandlerBase
response.zip = Settings.UseZip;
response.rar = Settings.UseRar;
response.pdf = Settings.UsePdf;
+ response.preprocessCount = Settings.MangaPagePreProcessCount;
+ response.preprocessDelay = Settings.MangaPagePreProcessDelay;
+ response.cacheLimit = Settings.MangaCacheSizeLimit;
ajax.ReturnJson(response);
}
View
15 source/haxe/afung/mangaWeb3/server/handler/AdminSettingsSetRequestHandler.hx
@@ -30,6 +30,21 @@ class AdminSettingsSetRequestHandler extends HandlerBase
Settings.UseZip = request.zip;
Settings.UseRar = request.rar;
Settings.UsePdf = request.pdf;
+
+ if (request.preprocessCount >= 0 && request.preprocessCount < 100)
+ {
+ Settings.MangaPagePreProcessCount = request.preprocessCount;
+ }
+
+ if (request.preprocessDelay >= 0 && request.preprocessDelay < 100000)
+ {
+ Settings.MangaPagePreProcessDelay = request.preprocessDelay;
+ }
+
+ if (request.cacheLimit >= 50 && request.cacheLimit < 100000)
+ {
+ Settings.MangaCacheSizeLimit = request.cacheLimit;
+ }
ajax.ReturnJson(new JsonResponse());
}
View
3 source/haxe/afung/mangaWeb3/server/install/handler/InstallRequestHandler.hx
@@ -68,6 +68,9 @@ class InstallRequestHandler extends HandlerBase
Settings.UsePdf = request.pdf;
Settings.AllowGuest = true;
Settings.LastAutoAddProcessTime = 0;
+ Settings.MangaPagePreProcessCount = 5;
+ Settings.MangaPagePreProcessDelay = 300;
+ Settings.MangaCacheSizeLimit = 200;
// Delete Install files
Native.Exec("rm -f ./install.html");
View
5 source/scriptsharp/Widget/FoldersWidget.cs
@@ -21,6 +21,11 @@ public FoldersWidget(jQueryObject parent, FolderJson[] folders, string folderPat
string separator = Environment.ServerType == ServerType.AspNet ? "\\" : "/";
attachedObject = Template.Get("client", "folders-table", true).AppendTo(parent).Attribute("data-path", folderPath);
+ ((List<FolderJson>)(object)folders).Sort(delegate(FolderJson a, FolderJson b)
+ {
+ return a.name.CompareTo(b.name); ;
+ });
+
foreach (FolderJson folder in folders)
{
string subfolderPath = folderPath + separator + folder.name;
View
2 source/scriptsharp/Widget/MangaListItem.cs
@@ -392,7 +392,7 @@ private static void LoadNextItem()
LoadNextItem();
},
- 1000);
+ 350);
}
}
}
View
7 source/scriptsharpadmin/Modal/AdminSettingsModal.cs
@@ -85,6 +85,10 @@ private void GetRequestSuccess(AdminSettingsGetResponse response)
{
jQuery.Select("#admin-settings-pdf").RemoveAttr("checked");
}
+
+ jQuery.Select("#admin-settings-preprocess-count").Value(response.preprocessCount.ToString());
+ jQuery.Select("#admin-settings-preprocess-delay").Value(response.preprocessDelay.ToString());
+ jQuery.Select("#admin-settings-cachelimit").Value(response.cacheLimit.ToString());
}
private void SubmitForm(jQueryEvent e)
@@ -96,6 +100,9 @@ private void SubmitForm(jQueryEvent e)
request.zip = jQuery.Select("#admin-settings-zip").GetAttribute("checked") == "checked";
request.rar = jQuery.Select("#admin-settings-rar").GetAttribute("checked") == "checked";
request.pdf = jQuery.Select("#admin-settings-pdf").GetAttribute("checked") == "checked";
+ request.preprocessCount = Number.IsFinite(request.preprocessCount = int.Parse(jQuery.Select("#admin-settings-preprocess-count").GetValue())) ? request.preprocessCount : -1;
+ request.preprocessDelay = Number.IsFinite(request.preprocessDelay = int.Parse(jQuery.Select("#admin-settings-preprocess-delay").GetValue())) ? request.preprocessDelay : -1;
+ request.cacheLimit = Number.IsFinite(request.cacheLimit = int.Parse(jQuery.Select("#admin-settings-cachelimit").GetValue())) ? request.cacheLimit : -1;
Request.Send(
request,

0 comments on commit 1e7824a

Please sign in to comment.
Something went wrong with that request. Please try again.