diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt
index 8bc6583..afbe847 100644
--- a/Builder/IISMainHandler/build.txt
+++ b/Builder/IISMainHandler/build.txt
@@ -1 +1 @@
-120
\ No newline at end of file
+126
\ No newline at end of file
diff --git a/Common/Common.csproj b/Common/Common.csproj
index 9d4be41..d56721e 100644
--- a/Common/Common.csproj
+++ b/Common/Common.csproj
@@ -48,8 +48,13 @@
+
+
+
+
+
diff --git a/Common/IOutputParams.cs b/Common/IOutputParams.cs
new file mode 100644
index 0000000..efd1f27
--- /dev/null
+++ b/Common/IOutputParams.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace FLocal.Common {
+
+ public interface IOutputParams {
+
+ string preprocessBodyIntermediate(string bodyIntermediate);
+
+ }
+}
diff --git a/Common/UserContext.cs b/Common/UserContext.cs
new file mode 100644
index 0000000..1cfe564
--- /dev/null
+++ b/Common/UserContext.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace FLocal.Common {
+ abstract public class UserContext {
+
+ public Common.Config config {
+ get {
+ return Common.Config.instance;
+ }
+ }
+
+ abstract public IOutputParams outputParams {
+ get;
+ }
+
+ abstract public dataobjects.IUserSettings userSettings {
+ get;
+ }
+
+ }
+
+}
diff --git a/Common/UserSettingsGateway.cs b/Common/UserSettingsGateway.cs
new file mode 100644
index 0000000..255f625
--- /dev/null
+++ b/Common/UserSettingsGateway.cs
@@ -0,0 +1,9 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace FLocal.Common {
+ class UserSettingsGateway {
+ }
+}
diff --git a/Common/dataobjects/AnonymousUserSettings.cs b/Common/dataobjects/AnonymousUserSettings.cs
new file mode 100644
index 0000000..3b4c552
--- /dev/null
+++ b/Common/dataobjects/AnonymousUserSettings.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace FLocal.Common.dataobjects {
+ public class AnonymousUserSettings : IUserSettings {
+
+ public int threadsPerPage {
+ get {
+ return 20;
+ }
+ }
+
+ public int postsPerPage {
+ get {
+ return 40;
+ }
+ }
+
+ }
+}
diff --git a/Common/dataobjects/Board.cs b/Common/dataobjects/Board.cs
index b1972f0..5f699c2 100644
--- a/Common/dataobjects/Board.cs
+++ b/Common/dataobjects/Board.cs
@@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
+using FLocal.Core;
+using FLocal.Core.DB;
namespace FLocal.Common.dataobjects {
public class Board : SqlObject {
@@ -17,6 +19,7 @@ namespace FLocal.Common.dataobjects {
public const string FIELD_TOTALTHREADS = "TotalThreads";
public const string FIELD_NAME = "Name";
public const string FIELD_DESCRIPTION = "Comment";
+ public const string FIELD_PARENTBOARDID = "ParentBoardId";
public static readonly TableSpec instance = new TableSpec();
public string name { get { return TABLE; } }
public string idName { get { return FIELD_ID; } }
@@ -32,8 +35,8 @@ namespace FLocal.Common.dataobjects {
}
}
- private int _categoryId;
- public int categoryId {
+ private int? _categoryId;
+ public int? categoryId {
get {
this.LoadIfNotLoaded();
return this._categoryId;
@@ -41,7 +44,7 @@ namespace FLocal.Common.dataobjects {
}
public Category category {
get {
- return Category.LoadById(this.categoryId);
+ return Category.LoadById(this.categoryId.Value);
}
}
@@ -85,22 +88,54 @@ namespace FLocal.Common.dataobjects {
}
}
+ private int? _parentBoardId;
+ public int? parentBoardId {
+ get {
+ this.LoadIfNotLoaded();
+ return this._parentBoardId;
+ }
+ }
+
protected override void doFromHash(Dictionary data) {
this._sortOrder = int.Parse(data[TableSpec.FIELD_SORTORDER]);
- this._categoryId = int.Parse(data[TableSpec.FIELD_CATEGORYID]);
- if(data[TableSpec.FIELD_LASTPOSTID] != "") {
- this._lastPostId = int.Parse(data[TableSpec.FIELD_LASTPOSTID]);
- } else {
- this._lastPostId = null;
- }
+ this._categoryId = Util.ParseInt(data[TableSpec.FIELD_CATEGORYID]);
+ this._lastPostId = Util.ParseInt(data[TableSpec.FIELD_LASTPOSTID]);
this._totalPosts = int.Parse(data[TableSpec.FIELD_TOTALPOSTS]);
this._totalThreads = int.Parse(data[TableSpec.FIELD_TOTALTHREADS]);
this._name = data[TableSpec.FIELD_NAME];
this._description = data[TableSpec.FIELD_DESCRIPTION];
+ this._parentBoardId = Util.ParseInt(data[TableSpec.FIELD_PARENTBOARDID]);
+ }
+
+ private readonly object subBoards_Locker = new object();
+ public IEnumerable subBoards {
+ get {
+ return
+ from id in Cache>.instance.get(
+ this.subBoards_Locker,
+ () => {
+ IEnumerable ids = from stringId in Config.instance.mainConnection.LoadIdsByConditions(
+ TableSpec.instance,
+ new FLocal.Core.DB.conditions.ComparisonCondition(
+ TableSpec.instance.getColumnSpec(Board.TableSpec.FIELD_PARENTBOARDID),
+ FLocal.Core.DB.conditions.ComparisonType.EQUAL,
+ this.id.ToString()
+ ),
+ Diapasone.unlimited,
+ new JoinSpec[0]
+ ) select int.Parse(stringId);
+ Board.LoadByIds(ids);
+ return ids;
+ }
+ )
+ let board = Board.LoadById(id)
+ orderby board.sortOrder, board.id
+ select board;
+ }
}
private bool hasNewPosts() {
- return Core.Util.RandomInt(0, 1) == 0;
+ return Core.Util.RandomInt(0, 1000) < 500;
}
private XElement exportLastPostInfo() {
@@ -111,8 +146,8 @@ namespace FLocal.Common.dataobjects {
}
}
- public XElement exportToXmlForMainPage() {
- return new XElement("board",
+ public XElement exportToXmlForMainPage(UserContext context) {
+ XElement result = new XElement("board",
new XElement("id", this.id),
new XElement("sortOrder", this.sortOrder),
new XElement("categoryId", this.categoryId),
@@ -123,6 +158,14 @@ namespace FLocal.Common.dataobjects {
new XElement("hasNewPosts", this.hasNewPosts() ? "true" : "false"),
new XElement("lastPostInfo", this.exportLastPostInfo())
);
+
+ if(!this.parentBoardId.HasValue) {
+ result.Add(new XElement("subBoards",
+ from board in this.subBoards select board.exportToXmlForMainPage(context)
+ ));
+ }
+
+ return result;
}
}
diff --git a/Common/dataobjects/Category.cs b/Common/dataobjects/Category.cs
index f39cdf0..c9ec45d 100644
--- a/Common/dataobjects/Category.cs
+++ b/Common/dataobjects/Category.cs
@@ -96,11 +96,11 @@ namespace FLocal.Common.dataobjects {
}
}
- public XElement exportToXmlForMainPage() {
+ public XElement exportToXmlForMainPage(UserContext context) {
return new XElement("category",
new XElement("name", this.name),
new XElement("sortOrder", this.sortOrder),
- new XElement("boards", from board in this.subBoards select board.exportToXmlForMainPage())
+ new XElement("boards", from board in this.subBoards select board.exportToXmlForMainPage(context))
);
}
diff --git a/Common/dataobjects/IUserSettings.cs b/Common/dataobjects/IUserSettings.cs
new file mode 100644
index 0000000..a0b3922
--- /dev/null
+++ b/Common/dataobjects/IUserSettings.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace FLocal.Common.dataobjects {
+ public interface IUserSettings {
+
+ int threadsPerPage {
+ get;
+ }
+
+ int postsPerPage {
+ get;
+ }
+
+ }
+}
diff --git a/Core/Util.cs b/Core/Util.cs
index c3649cc..f5223fd 100644
--- a/Core/Util.cs
+++ b/Core/Util.cs
@@ -112,6 +112,14 @@ namespace FLocal.Core {
return RandomString(length, RandomSource.LETTERS);
}
+ public static int? ParseInt(string raw) {
+ if(raw == "") {
+ return null;
+ } else {
+ return int.Parse(raw);
+ }
+ }
+
}
}
diff --git a/IISMainHandler/TemplateEngine.cs b/IISMainHandler/TemplateEngine.cs
index 81ac382..7614433 100644
--- a/IISMainHandler/TemplateEngine.cs
+++ b/IISMainHandler/TemplateEngine.cs
@@ -34,7 +34,7 @@ namespace FLocal.IISHandler {
public static string Compile(string templateName, XDocument data) {
StringBuilder builder = new StringBuilder();
- using(XmlWriter writer = XmlWriter.Create(builder, new XmlWriterSettings { Indent = true, NewLineHandling = NewLineHandling.None})) {
+ using(XmlWriter writer = XmlWriter.Create(builder, new XmlWriterSettings { Indent = false })) {
using(XmlReader reader = data.CreateReader()) {
TemplateCacher.instance.getCompiledTransform(templateName).Transform(reader, writer);
}
diff --git a/IISMainHandler/WebContext.cs b/IISMainHandler/WebContext.cs
index 9d0aaea..37d5da6 100644
--- a/IISMainHandler/WebContext.cs
+++ b/IISMainHandler/WebContext.cs
@@ -5,7 +5,7 @@ using System.Text;
using System.Web;
namespace FLocal.IISHandler {
- class WebContext {
+ class WebContext : Common.UserContext {
public readonly HttpContext httpcontext;
@@ -21,15 +21,21 @@ namespace FLocal.IISHandler {
}
}
- public designs.IDesign design {
+ public override Common.dataobjects.IUserSettings userSettings {
get {
- return new designs.Classic();
+ return new Common.dataobjects.AnonymousUserSettings();
+ }
+ }
+
+ public override Common.IOutputParams outputParams {
+ get {
+ return this.design;
}
}
- public Common.Config config {
+ public designs.IDesign design {
get {
- return Common.Config.instance;
+ return new designs.Classic();
}
}
diff --git a/IISMainHandler/designs/Classic.cs b/IISMainHandler/designs/Classic.cs
index 8ca9b5a..cb2d3d3 100644
--- a/IISMainHandler/designs/Classic.cs
+++ b/IISMainHandler/designs/Classic.cs
@@ -10,5 +10,12 @@ namespace FLocal.IISHandler.designs {
return "Full";
}
}
+
+ string FLocal.Common.IOutputParams.preprocessBodyIntermediate(string bodyIntermediate) {
+ return bodyIntermediate.
+ Replace("", "", "\" alt=\"").
+ Replace("", "\"/>");
+ }
}
}
diff --git a/IISMainHandler/designs/IDesign.cs b/IISMainHandler/designs/IDesign.cs
index b411e7f..e5f7ee3 100644
--- a/IISMainHandler/designs/IDesign.cs
+++ b/IISMainHandler/designs/IDesign.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
namespace FLocal.IISHandler.designs {
- interface IDesign {
+ interface IDesign : Common.IOutputParams {
string fsname {
get;
diff --git a/IISMainHandler/designs/Lite.cs b/IISMainHandler/designs/Lite.cs
index 85941f0..93b6625 100644
--- a/IISMainHandler/designs/Lite.cs
+++ b/IISMainHandler/designs/Lite.cs
@@ -10,5 +10,12 @@ namespace FLocal.IISHandler.designs {
return "Lite";
}
}
+
+ string FLocal.Common.IOutputParams.preprocessBodyIntermediate(string bodyIntermediate) {
+ return bodyIntermediate.
+ Replace("", "", "\">").
+ Replace("", "");
+ }
}
}
diff --git a/IISMainHandler/handlers/AbstractGetHandler.cs b/IISMainHandler/handlers/AbstractGetHandler.cs
index e68bbf8..d6841e1 100644
--- a/IISMainHandler/handlers/AbstractGetHandler.cs
+++ b/IISMainHandler/handlers/AbstractGetHandler.cs
@@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Xml.Linq;
+using FLocal.Common;
namespace FLocal.IISHandler.handlers {
abstract class AbstractGetHandler : ISpecificHandler {
@@ -10,7 +12,16 @@ namespace FLocal.IISHandler.handlers {
get;
}
- abstract protected System.Xml.Linq.XDocument getData(WebContext context);
+ abstract protected XElement[] getSpecificData(WebContext context);
+
+ private XDocument getData(WebContext context) {
+ return new XDocument(
+ new XElement("root",
+ new XElement("title", Config.instance.AppInfo),
+ this.getSpecificData(context)
+ )
+ );
+ }
public void Handle(WebContext context) {
context.httpresponse.Write(context.Transform(this.templateName, this.getData(context)));
diff --git a/IISMainHandler/handlers/BoardsHandler.cs b/IISMainHandler/handlers/BoardsHandler.cs
index 10af8d9..c8ae6b8 100644
--- a/IISMainHandler/handlers/BoardsHandler.cs
+++ b/IISMainHandler/handlers/BoardsHandler.cs
@@ -17,16 +17,8 @@ namespace FLocal.IISHandler.handlers {
}
}
- override protected XDocument getData(WebContext context) {
- Board board1 = Board.LoadById(1);
- Board board2 = Board.LoadById(2);
- Board board3 = Board.LoadById(4);
- return new XDocument(
- new XElement("root",
- new XElement("title", Config.instance.AppInfo),
- new XElement("categories", from category in Category.allCategories select category.exportToXmlForMainPage())
- )
- );
+ override protected XElement[] getSpecificData(WebContext context) {
+ return new XElement[] { new XElement("categories", from category in Category.allCategories select category.exportToXmlForMainPage(context)) };
}
}
diff --git a/IISMainHandler/handlers/RootHandler.cs b/IISMainHandler/handlers/RootHandler.cs
index 4bbf602..a1773a4 100644
--- a/IISMainHandler/handlers/RootHandler.cs
+++ b/IISMainHandler/handlers/RootHandler.cs
@@ -15,7 +15,7 @@ namespace FLocal.IISHandler.handlers {
}
}
- override protected XDocument getData(WebContext context) {
+ override protected XElement[] getSpecificData(WebContext context) {
throw new NotImplementedException();
}
diff --git a/templates/Full/Boards.xslt b/templates/Full/Boards.xslt
index e8a07ad..626eb07 100644
--- a/templates/Full/Boards.xslt
+++ b/templates/Full/Boards.xslt
@@ -106,6 +106,14 @@
|
+
+
+ |
+
+
+ |
+
+
|
@@ -134,4 +142,13 @@
+
+
+
+
+ /Threads//
+
+
+
+
\ No newline at end of file