Skip to content

Commit

Permalink
Added RSSWebInterace (empty).
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzaQ committed Mar 3, 2017
1 parent 644f29a commit ff60d66
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 16 deletions.
4 changes: 2 additions & 2 deletions source/pierun/core.d
Expand Up @@ -36,14 +36,14 @@ class Post
{
enum Status
{
Ok,
Public,
Unlisted,
Private
}

@Generated @Id int id;
User author;
int status = cast(int)Status.Ok;
int status = cast(int)Status.Public;
DateTime published;
PostData[] edits;
Language language;
Expand Down
4 changes: 3 additions & 1 deletion source/pierun/interfaces/admin.d
@@ -1,3 +1,5 @@
module pierun.interfaces.admin;

import vibe.d;
import vibe.web.auth;

Expand All @@ -7,7 +9,7 @@ import pierun.core;
import pierun.utils.dbcache;
import pierun.interfaces.web;

import common;
import pierun.interfaces.common;

@requiresAuth
class AdminWebInterface
Expand Down
2 changes: 2 additions & 0 deletions source/pierun/interfaces/common.d
@@ -1,3 +1,5 @@
module pierun.interfaces.common;

import pierun.utils.dbcache;

struct AuthInfo
Expand Down
25 changes: 25 additions & 0 deletions source/pierun/interfaces/rss.d
@@ -0,0 +1,25 @@
module pierun.interfaces.rss;

import vibe.d;
import vibe.web.auth;

import pierun.interfaces.common,
pierun.interfaces.web;

@requiresAuth
class RSSWebInterface
{
private {
WebInterface parent;
}

this(WebInterface wi) {
parent = wi;
}

@noRoute
auto authenticate(HTTPServerRequest req, HTTPServerResponse res)
{
return parent.authenticate(req, res);
}
}
22 changes: 9 additions & 13 deletions source/pierun/interfaces/web.d
Expand Up @@ -10,7 +10,9 @@ import hibernated.core;
import pierun.core;
import pierun.utils.dbcache, pierun.utils.misc;

import common, admin;
import pierun.interfaces.common,
pierun.interfaces.admin,
pierun.interfaces.rss;

@requiresAuth
class WebInterface
Expand All @@ -20,9 +22,11 @@ class WebInterface
DBSession sessionMember;
DBCache dbCacheMember;
AdminWebInterface adminWebInterface;
RSSWebInterface rssWebInterace;
}

@property AdminWebInterface admin() { return adminWebInterface; }
@property RSSWebInterface rss() { return rssWebInterace; }

@noRoute @property DBCache dbCache() { return dbCacheMember; }
@noRoute @property DBSession session() { return sessionMember; }
Expand All @@ -41,13 +45,16 @@ class WebInterface
this.sessionMember = s;
this.dbCacheMember = new DBCache(s);
this.adminWebInterface = new AdminWebInterface(this);
this.rssWebInterace = new RSSWebInterface(this);
}

@noAuth
void index(HTTPServerRequest req, HTTPServerResponse res)
{
Post[] posts = session
.createQuery("FROM Post WHERE status = 0")
.createQuery("SELECT P FROM Post AS P " ~
"WHERE status = 0 " ~
"ORDER BY P.published DESC")
.list!Post;

render!("index.dt", posts);
Expand Down Expand Up @@ -85,17 +92,6 @@ class WebInterface
redirect("/");
}

//@noAuth
//void post(HTTPServerRequest req, string markdown)
//{
// import pierun.utils.markdown;
// import std.conv;

// markdown = pierun.utils.markdown.parseMarkdown(markdown);

// render!("index.dt", markdown);
//}

@path("/post/:id/*") @noAuth @errorDisplay!error
void getPostIdName(scope HTTPServerRequest req, scope HTTPServerResponse res)
{
Expand Down

0 comments on commit ff60d66

Please sign in to comment.