'Reversed' pageouter option implemented

main
Inga 🏳‍🌈 14 years ago
parent 9f6fc58d79
commit a14a0e6c99
  1. 2
      Builder/IISMainHandler/build.txt
  2. 4
      Common/dataobjects/Board.cs
  3. 8
      Common/dataobjects/PMConversation.cs
  4. 4
      Common/dataobjects/Thread.cs
  5. 16
      Common/dataobjects/User.cs
  6. 42
      IISMainHandler/PageOuter.cs
  7. 2
      IISMainHandler/handlers/BoardHandler.cs
  8. 2
      IISMainHandler/handlers/ThreadHandler.cs
  9. 2
      IISMainHandler/handlers/response/AllPostsHandler.cs
  10. 2
      IISMainHandler/handlers/response/AllThreadsHandler.cs
  11. 2
      IISMainHandler/handlers/response/BoardAsThread.cs
  12. 2
      IISMainHandler/handlers/response/ConversationHandler.cs
  13. 2
      IISMainHandler/handlers/response/ConversationsHandler.cs
  14. 4
      IISMainHandler/handlers/response/UploadListHandler.cs
  15. 2
      IISMainHandler/handlers/response/UserListHandler.cs
  16. 2
      IISMainHandler/handlers/response/UserPollsParticipatedHandler.cs
  17. 2
      IISMainHandler/handlers/response/UserPostsHandler.cs
  18. 2
      IISMainHandler/handlers/response/UserRepliesHandler.cs
  19. 2
      IISMainHandler/handlers/response/UserThreadsHandler.cs

@ -332,7 +332,7 @@ namespace FLocal.Common.dataobjects {
);
}
public IEnumerable<Thread> getThreads(Diapasone diapasone) {
public IEnumerable<Thread> getThreads(Diapasone diapasone, bool isAscending) {
return this.getThreads(
diapasone,
new SortSpec[] {
@ -342,7 +342,7 @@ namespace FLocal.Common.dataobjects {
),
new SortSpec(
Thread.TableSpec.instance.getColumnSpec(Thread.TableSpec.FIELD_LASTPOSTID),
false
isAscending
),
}
);

@ -155,7 +155,7 @@ namespace FLocal.Common.dataobjects {
return result;
}
public IEnumerable<PMMessage> getMessages(Diapasone diapasone, UserContext context) {
public IEnumerable<PMMessage> getMessages(Diapasone diapasone, UserContext context, bool isAscending) {
return PMMessage.LoadByIds(
from stringId in Config.instance.mainConnection.LoadIdsByConditions(
PMMessage.TableSpec.instance,
@ -177,7 +177,7 @@ namespace FLocal.Common.dataobjects {
new SortSpec[] {
new SortSpec(
PMMessage.TableSpec.instance.getIdSpec(),
true
isAscending
),
}
) select int.Parse(stringId)
@ -240,7 +240,7 @@ namespace FLocal.Common.dataobjects {
});
}
public static IEnumerable<PMConversation> getConversations(Account owner, Diapasone diapasone) {
public static IEnumerable<PMConversation> getConversations(Account owner, Diapasone diapasone, bool isAscending) {
return LoadByIds(
from stringId in Config.instance.mainConnection.LoadIdsByConditions(
TableSpec.instance,
@ -254,7 +254,7 @@ namespace FLocal.Common.dataobjects {
new SortSpec[] {
new SortSpec(
TableSpec.instance.getColumnSpec(TableSpec.FIELD_LASTMESSAGEID),
false
isAscending
)
}
) select int.Parse(stringId)

@ -230,7 +230,7 @@ namespace FLocal.Common.dataobjects {
return result;
}
public IEnumerable<Post> getPosts(Diapasone diapasone) {
public IEnumerable<Post> getPosts(Diapasone diapasone, bool isAscending) {
return Post.LoadByIds(
from stringId in Config.instance.mainConnection.LoadIdsByConditions(
Post.TableSpec.instance,
@ -244,7 +244,7 @@ namespace FLocal.Common.dataobjects {
new SortSpec[] {
new SortSpec(
Post.TableSpec.instance.getIdSpec(),
true
isAscending
),
}
) select int.Parse(stringId)

@ -208,7 +208,7 @@ namespace FLocal.Common.dataobjects {
return result;
}
public static IEnumerable<User> getUsers(Diapasone diapasone) {
public static IEnumerable<User> getUsers(Diapasone diapasone, bool isAscending) {
return User.LoadByIds(
from stringId in Config.instance.mainConnection.LoadIdsByConditions(
User.TableSpec.instance,
@ -218,7 +218,7 @@ namespace FLocal.Common.dataobjects {
new SortSpec[] {
new SortSpec(
User.TableSpec.instance.getIdSpec(),
true
isAscending
),
}
) select int.Parse(stringId)
@ -231,7 +231,7 @@ namespace FLocal.Common.dataobjects {
return desiredLayer;
}
public IEnumerable<Post> getPosts(Diapasone diapasone) {
public IEnumerable<Post> getPosts(Diapasone diapasone, bool isAscending) {
return Post.LoadByIds(
from stringId in Config.instance.mainConnection.LoadIdsByConditions(
Post.TableSpec.instance,
@ -245,14 +245,14 @@ namespace FLocal.Common.dataobjects {
new SortSpec[] {
new SortSpec(
Post.TableSpec.instance.getIdSpec(),
false
isAscending
),
}
) select int.Parse(stringId)
);
}
public IEnumerable<Post> getReplies(Diapasone diapasone) {
public IEnumerable<Post> getReplies(Diapasone diapasone, bool isAscending) {
JoinSpec parent = new JoinSpec(
Post.TableSpec.instance.getColumnSpec(Post.TableSpec.FIELD_PARENTPOSTID),
Post.TableSpec.instance,
@ -281,14 +281,14 @@ namespace FLocal.Common.dataobjects {
new SortSpec[] {
new SortSpec(
Post.TableSpec.instance.getIdSpec(),
false
isAscending
),
}
) select int.Parse(stringId)
);
}
public IEnumerable<Thread> getThreads(Diapasone diapasone) {
public IEnumerable<Thread> getThreads(Diapasone diapasone, bool isAscending) {
return Thread.LoadByIds(
from stringId in Config.instance.mainConnection.LoadIdsByConditions(
Thread.TableSpec.instance,
@ -302,7 +302,7 @@ namespace FLocal.Common.dataobjects {
new SortSpec[] {
new SortSpec(
Thread.TableSpec.instance.getColumnSpec(Thread.TableSpec.FIELD_LASTPOSTID),
false
isAscending
),
}
) select int.Parse(stringId)

@ -11,54 +11,64 @@ namespace FLocal.IISHandler {
public readonly long perPage;
private PageOuter(long start, long count, long perPage)
public readonly bool reversed;
public bool ascendingDirection {
get {
return !this.reversed;
}
}
public bool descendingDirection {
get {
return this.reversed;
}
}
private PageOuter(long start, long count, long perPage, bool reversed)
: base(start, count) {
this.perPage = perPage;
this.reversed = reversed;
}
private PageOuter(long perPage)
private PageOuter(long perPage, bool reversed)
: base(0, -1) {
this.perPage = perPage;
this.reversed = reversed;
}
public static PageOuter createUnlimited(long perPage) {
return new PageOuter(perPage);
return new PageOuter(perPage, false);
}
public static PageOuter create(long perPage, long total) {
PageOuter result = new PageOuter(0, perPage, perPage);
PageOuter result = new PageOuter(0, perPage, perPage, false);
result.total = total;
return result;
}
public static PageOuter createFromGet(string[] requestParts, long perPage, Dictionary<char, Func<long>> customAction, int offset) {
bool reversed = (requestParts.Length > (offset+1)) && (requestParts[offset+1].ToLower() == "reversed");
if(requestParts.Length > offset) {
if(requestParts[offset].ToLower() == "all") {
return new PageOuter(perPage);
return new PageOuter(perPage, reversed);
} else if(Char.IsDigit(requestParts[offset][0])) {
return new PageOuter(long.Parse(requestParts[offset]), perPage, perPage);
return new PageOuter(long.Parse(requestParts[offset]), perPage, perPage, reversed);
} else {
return new PageOuter(customAction[requestParts[offset][0]](), perPage, perPage);
return new PageOuter(customAction[requestParts[offset][0]](), perPage, perPage, reversed);
}
} else {
return new PageOuter(0, perPage, perPage);
return new PageOuter(0, perPage, perPage, reversed);
}
}
/*public static PageOuter createFromGet(string[] requestParts, long perPage, Dictionary<char, Func<long>> customAction) {
return createFromGet(requestParts, perPage, customAction, 2);
}*/
public static PageOuter createFromGet(string[] requestParts, long perPage, int offset) {
return createFromGet(requestParts, perPage, new Dictionary<char, Func<long>>(), offset);
}
/*public static PageOuter createFromGet(string[] requestParts, long perPage) {
return createFromGet(requestParts, perPage, new Dictionary<char,Func<long>>());
}*/
public XElement exportToXml(int left, int current, int right) {
XElement result = new XElement("pageOuter",
new XElement("isReversed", this.reversed),
new XElement("unlimited", (this.count < 1).ToPlainString()),
new XElement("start", this.start),
new XElement("count", this.count),

@ -22,7 +22,7 @@ namespace FLocal.IISHandler.handlers {
override protected IEnumerable<XElement> getSpecificData(WebContext context) {
Board board = Board.LoadById(int.Parse(context.requestParts[1]));
PageOuter pageOuter = PageOuter.createFromGet(context.requestParts, context.userSettings.threadsPerPage, 2);
IEnumerable<Thread> threads = board.getThreads(pageOuter);
IEnumerable<Thread> threads = board.getThreads(pageOuter, pageOuter.descendingDirection);
XElement[] result = new XElement[] {
new XElement("currentLocation", board.exportToXmlSimpleWithParent(context)),
new XElement("boards", from subBoard in board.subBoards select subBoard.exportToXml(context, Board.SubboardsOptions.FirstLevel)),

@ -48,7 +48,7 @@ namespace FLocal.IISHandler.handlers {
},
2
);
IEnumerable<Post> posts = thread.getPosts(pageOuter);
IEnumerable<Post> posts = thread.getPosts(pageOuter, pageOuter.ascendingDirection);
int lastReadId = 0;
if(context.session != null) {

@ -40,7 +40,7 @@ namespace FLocal.IISHandler.handlers.response {
new SortSpec[] {
new SortSpec(
Post.TableSpec.instance.getIdSpec(),
false
pageOuter.descendingDirection
)
}
)

@ -40,7 +40,7 @@ namespace FLocal.IISHandler.handlers.response {
new SortSpec[] {
new SortSpec(
Thread.TableSpec.instance.getColumnSpec(Thread.TableSpec.FIELD_LASTPOSTID),
false
pageOuter.descendingDirection
)
}
)

@ -26,7 +26,7 @@ namespace FLocal.IISHandler.handlers.response {
new SortSpec[] {
new SortSpec(
Thread.TableSpec.instance.getColumnSpec(Thread.TableSpec.FIELD_ID),
true
pageOuter.ascendingDirection
),
}
);

@ -54,7 +54,7 @@ namespace FLocal.IISHandler.handlers.response {
},
4
);
IEnumerable<PMMessage> messages = conversation.getMessages(pageOuter, context);
IEnumerable<PMMessage> messages = conversation.getMessages(pageOuter, context, pageOuter.ascendingDirection);
XElement[] result = new XElement[] {
conversation.exportToXml(context, false),

@ -21,7 +21,7 @@ namespace FLocal.IISHandler.handlers.response {
override protected IEnumerable<XElement> getSpecificData(WebContext context) {
PageOuter pageOuter = PageOuter.createFromGet(context.requestParts, context.userSettings.threadsPerPage, 2);
IEnumerable<PMConversation> conversations = PMConversation.getConversations(context.session.account, pageOuter);
IEnumerable<PMConversation> conversations = PMConversation.getConversations(context.session.account, pageOuter, pageOuter.descendingDirection);
XElement[] result = new XElement[] {
new XElement("conversations",
from conversation in conversations select conversation.exportToXml(context, false),

@ -30,11 +30,11 @@ namespace FLocal.IISHandler.handlers.response {
new SortSpec[] {
new SortSpec(
Upload.TableSpec.instance.getColumnSpec(Upload.TableSpec.FIELD_UPLOADDATE),
true
pageOuter.ascendingDirection
),
new SortSpec(
Upload.TableSpec.instance.getIdSpec(),
true
pageOuter.ascendingDirection
),
}
) select int.Parse(stringId)

@ -20,7 +20,7 @@ namespace FLocal.IISHandler.handlers.response {
override protected IEnumerable<XElement> getSpecificData(WebContext context) {
PageOuter pageOuter = PageOuter.createFromGet(context.requestParts, context.userSettings.usersPerPage, 2);
IEnumerable<User> users = User.getUsers(pageOuter);
IEnumerable<User> users = User.getUsers(pageOuter, pageOuter.ascendingDirection);
return new XElement[] {
new XElement("users",
from user in users select user.exportToXmlForViewing(context),

@ -39,7 +39,7 @@ namespace FLocal.IISHandler.handlers.response {
new SortSpec[] {
new SortSpec(
Poll.Vote.TableSpec.instance.getIdSpec(),
false
pageOuter.descendingDirection
)
}
) select int.Parse(stringId)

@ -26,7 +26,7 @@ namespace FLocal.IISHandler.handlers.response {
context.userSettings.postsPerPage,
4
);
IEnumerable<Post> posts = user.getPosts(pageOuter);
IEnumerable<Post> posts = user.getPosts(pageOuter, pageOuter.descendingDirection);
return new XElement[] {
new XElement("posts",

@ -26,7 +26,7 @@ namespace FLocal.IISHandler.handlers.response {
context.userSettings.postsPerPage,
4
);
IEnumerable<Post> posts = user.getReplies(pageOuter);
IEnumerable<Post> posts = user.getReplies(pageOuter, pageOuter.descendingDirection);
return new XElement[] {
user.exportToXmlForViewing(context),

@ -26,7 +26,7 @@ namespace FLocal.IISHandler.handlers.response {
context.userSettings.postsPerPage,
4
);
IEnumerable<Thread> threads = user.getThreads(pageOuter);
IEnumerable<Thread> threads = user.getThreads(pageOuter, pageOuter.descendingDirection);
return new XElement[] {
new XElement("threads",

Loading…
Cancel
Save