From 2ed9f969f2cbd10d66461428e87e38d26a85f029 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sun, 7 Sep 2014 19:49:11 +0200 Subject: [PATCH] Added presenter placeholders --- data/config.ini | 7 ++++ public_html/index.html | 8 +++++ public_html/js/Auth.js | 7 ++++ .../js/Presenters/CommentListPresenter.js | 26 +++++++++++++++ public_html/js/Presenters/HelpPresenter.js | 26 +++++++++++++++ public_html/js/Presenters/HomePresenter.js | 26 +++++++++++++++ .../js/Presenters/PasswordResetPresenter.js | 32 +++++++++++++++++++ .../js/Presenters/PostListPresenter.js | 26 +++++++++++++++ .../js/Presenters/PostUploadPresenter.js | 26 +++++++++++++++ public_html/js/Presenters/TagListPresenter.js | 26 +++++++++++++++ .../js/Presenters/TopNavigationPresenter.js | 7 +++- .../js/Presenters/UserActivationPresenter.js | 26 +++++++++++++++ public_html/js/Router.js | 16 +++++++--- public_html/js/Util.js | 2 +- public_html/templates/login-form.tpl | 2 +- public_html/templates/top-navigation.tpl | 30 ++++++++++++++++- src/Privilege.php | 7 ++++ 17 files changed, 291 insertions(+), 9 deletions(-) create mode 100644 public_html/js/Presenters/CommentListPresenter.js create mode 100644 public_html/js/Presenters/HelpPresenter.js create mode 100644 public_html/js/Presenters/HomePresenter.js create mode 100644 public_html/js/Presenters/PasswordResetPresenter.js create mode 100644 public_html/js/Presenters/PostListPresenter.js create mode 100644 public_html/js/Presenters/PostUploadPresenter.js create mode 100644 public_html/js/Presenters/TagListPresenter.js create mode 100644 public_html/js/Presenters/UserActivationPresenter.js diff --git a/data/config.ini b/data/config.ini index cb7a6194..f47f84d6 100644 --- a/data/config.ini +++ b/data/config.ini @@ -23,6 +23,13 @@ changeAllNames = moderator, administrator changeAllPasswords = moderator, administrator changeAccessRank = administrator +listSafePosts = anonymous, regularUser, powerUser, moderator, administrator +listSketchyPosts = anonymous, regularUser, powerUser, moderator, administrator +listUnsafePosts = anonymous, regularUser, powerUser, moderator, administrator +uploadPosts = regularUser, powerUser, moderator, administrator + +listTags = anonymous, regularUser, powerUser, moderator, administrator + [users] minUserNameLength = 1 maxUserNameLength = 32 diff --git a/public_html/index.html b/public_html/index.html index 840a7858..1302f5c7 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -47,6 +47,14 @@ + + + + + + + + diff --git a/public_html/js/Auth.js b/public_html/js/Auth.js index cdaeb0fb..f8301093 100644 --- a/public_html/js/Auth.js +++ b/public_html/js/Auth.js @@ -17,6 +17,13 @@ App.Auth = function(jQuery, util, api, appState, promise) { changeAllPasswords: 'changeAllPasswords', deleteOwnAccount: 'deleteOwnAccount', deleteAllAccounts: 'deleteAllAccounts', + + listSafePosts: 'listSafePosts', + listSketchyPosts: 'listSketchyPosts', + listUnsafePosts: 'listUnsafePosts', + uploadPosts: 'uploadPosts', + + listTags: 'listTags', }; function loginFromCredentials(userName, password, remember) { diff --git a/public_html/js/Presenters/CommentListPresenter.js b/public_html/js/Presenters/CommentListPresenter.js new file mode 100644 index 00000000..d1df32ac --- /dev/null +++ b/public_html/js/Presenters/CommentListPresenter.js @@ -0,0 +1,26 @@ +var App = App || {}; +App.Presenters = App.Presenters || {}; + +App.Presenters.CommentListPresenter = function( + jQuery, + topNavigationPresenter) { + + var $el = jQuery('#content'); + + function init(args) { + topNavigationPresenter.select('comments'); + render(); + } + + function render() { + $el.html('Comment list placeholder'); + }; + + return { + init: init, + render: render, + }; + +}; + +App.DI.register('commentListPresenter', App.Presenters.CommentListPresenter); diff --git a/public_html/js/Presenters/HelpPresenter.js b/public_html/js/Presenters/HelpPresenter.js new file mode 100644 index 00000000..a2a8c8de --- /dev/null +++ b/public_html/js/Presenters/HelpPresenter.js @@ -0,0 +1,26 @@ +var App = App || {}; +App.Presenters = App.Presenters || {}; + +App.Presenters.HelpPresenter = function( + jQuery, + topNavigationPresenter) { + + var $el = jQuery('#content'); + + function init(args) { + topNavigationPresenter.select('help'); + render(); + } + + function render() { + $el.html('Help placeholder'); + }; + + return { + init: init, + render: render, + }; + +}; + +App.DI.register('helpPresenter', App.Presenters.HelpPresenter); diff --git a/public_html/js/Presenters/HomePresenter.js b/public_html/js/Presenters/HomePresenter.js new file mode 100644 index 00000000..1e9c978d --- /dev/null +++ b/public_html/js/Presenters/HomePresenter.js @@ -0,0 +1,26 @@ +var App = App || {}; +App.Presenters = App.Presenters || {}; + +App.Presenters.HomePresenter = function( + jQuery, + topNavigationPresenter) { + + var $el = jQuery('#content'); + + function init(args) { + topNavigationPresenter.select('home'); + render(); + } + + function render() { + $el.html('Home placeholder'); + }; + + return { + init: init, + render: render, + }; + +}; + +App.DI.register('homePresenter', App.Presenters.HomePresenter); diff --git a/public_html/js/Presenters/PasswordResetPresenter.js b/public_html/js/Presenters/PasswordResetPresenter.js new file mode 100644 index 00000000..b5380e03 --- /dev/null +++ b/public_html/js/Presenters/PasswordResetPresenter.js @@ -0,0 +1,32 @@ +var App = App || {}; +App.Presenters = App.Presenters || {}; + +App.Presenters.PasswordResetPresenter = function( + jQuery, + topNavigationPresenter, + messagePresenter) { + + var $el = jQuery('#content'); + var $messages = $el; + + function init(args) { + topNavigationPresenter.select('login'); + if (args.token) { + alert('Got token'); + } else { + render(); + } + } + + function render() { + $el.html('Password reset placeholder'); + }; + + return { + init: init, + render: render, + }; + +}; + +App.DI.register('passwordResetPresenter', App.Presenters.PasswordResetPresenter); diff --git a/public_html/js/Presenters/PostListPresenter.js b/public_html/js/Presenters/PostListPresenter.js new file mode 100644 index 00000000..b40d1354 --- /dev/null +++ b/public_html/js/Presenters/PostListPresenter.js @@ -0,0 +1,26 @@ +var App = App || {}; +App.Presenters = App.Presenters || {}; + +App.Presenters.PostListPresenter = function( + jQuery, + topNavigationPresenter) { + + var $el = jQuery('#content'); + + function init(args) { + topNavigationPresenter.select('posts'); + render(); + } + + function render() { + $el.html('Post list placeholder'); + }; + + return { + init: init, + render: render, + }; + +}; + +App.DI.register('postListPresenter', App.Presenters.PostListPresenter); diff --git a/public_html/js/Presenters/PostUploadPresenter.js b/public_html/js/Presenters/PostUploadPresenter.js new file mode 100644 index 00000000..fba01375 --- /dev/null +++ b/public_html/js/Presenters/PostUploadPresenter.js @@ -0,0 +1,26 @@ +var App = App || {}; +App.Presenters = App.Presenters || {}; + +App.Presenters.PostUploadPresenter = function( + jQuery, + topNavigationPresenter) { + + var $el = jQuery('#content'); + + function init(args) { + topNavigationPresenter.select('upload'); + render(); + } + + function render() { + $el.html('Post upload placeholder'); + }; + + return { + init: init, + render: render, + }; + +}; + +App.DI.register('postUploadPresenter', App.Presenters.PostUploadPresenter); diff --git a/public_html/js/Presenters/TagListPresenter.js b/public_html/js/Presenters/TagListPresenter.js new file mode 100644 index 00000000..c36b728d --- /dev/null +++ b/public_html/js/Presenters/TagListPresenter.js @@ -0,0 +1,26 @@ +var App = App || {}; +App.Presenters = App.Presenters || {}; + +App.Presenters.TagListPresenter = function( + jQuery, + topNavigationPresenter) { + + var $el = jQuery('#content'); + + function init(args) { + topNavigationPresenter.select('tags'); + render(); + } + + function render() { + $el.html('Tag list placeholder'); + }; + + return { + init: init, + render: render, + }; + +}; + +App.DI.register('tagListPresenter', App.Presenters.TagListPresenter); diff --git a/public_html/js/Presenters/TopNavigationPresenter.js b/public_html/js/Presenters/TopNavigationPresenter.js index b8c35298..6f91c791 100644 --- a/public_html/js/Presenters/TopNavigationPresenter.js +++ b/public_html/js/Presenters/TopNavigationPresenter.js @@ -33,7 +33,12 @@ App.Presenters.TopNavigationPresenter = function( $el.html(template({ loggedIn: auth.isLoggedIn(), user: auth.getCurrentUser(), - canListUsers: auth.hasPrivilege(auth.privileges.listUsers) + canListUsers: auth.hasPrivilege(auth.privileges.listUsers), + canListPosts: auth.hasPrivilege(auth.privileges.listSafePosts) || + auth.hasPrivilege(auth.privileges.listSketchyPosts) || + auth.hasPrivilege(auth.privileges.listUnsafePosts), + canListTags: auth.hasPrivilege(auth.privileges.listTags), + canUploadPosts: auth.hasPrivilege(auth.privileges.uploadPosts), })); $el.find('li.' + selectedElement).addClass('active'); }; diff --git a/public_html/js/Presenters/UserActivationPresenter.js b/public_html/js/Presenters/UserActivationPresenter.js new file mode 100644 index 00000000..58accd67 --- /dev/null +++ b/public_html/js/Presenters/UserActivationPresenter.js @@ -0,0 +1,26 @@ +var App = App || {}; +App.Presenters = App.Presenters || {}; + +App.Presenters.UserActivationPresenter = function( + jQuery, + topNavigationPresenter) { + + var $el = jQuery('#content'); + + function init(args) { + topNavigationPresenter.select('login'); + render(); + } + + function render() { + $el.html('Account activation placeholder'); + }; + + return { + init: init, + render: render, + }; + +}; + +App.DI.register('userActivationPresenter', App.Presenters.UserActivationPresenter); diff --git a/public_html/js/Router.js b/public_html/js/Router.js index b32176f9..4bdebb31 100644 --- a/public_html/js/Router.js +++ b/public_html/js/Router.js @@ -19,14 +19,20 @@ App.Router = function(jQuery, util, appState) { }; function injectRoutes() { + inject('#/home', 'homePresenter'); inject('#/login', 'loginPresenter'); inject('#/logout', 'logoutPresenter'); inject('#/register', 'registrationPresenter'); - inject('#/users', 'userListPresenter'); - inject('#/users/:searchArgs', 'userListPresenter'); - inject('#/user/:userName', 'userPresenter'); - inject('#/user/:userName/:tab', 'userPresenter'); - setRoot('#/users'); + inject('#/upload', 'postUploadPresenter'); + inject('#/password-reset(/:token)', 'passwordResetPresenter'); + inject('#/activate(/:token)', 'userActivationPresenter'); + inject('#/users(/:searchArgs)', 'userListPresenter'); + inject('#/user/:userName(/:tab)', 'userPresenter'); + inject('#/posts(/:searchArgs)', 'postListPresenter'); + inject('#/comments(/:searchArgs)', 'commentListPresenter'); + inject('#/tags(/:searchArgs)', 'tagListPresenter'); + inject('#/help', 'helpPresenter'); + setRoot('#/home'); }; function setRoot(newRoot) { diff --git a/public_html/js/Util.js b/public_html/js/Util.js index 1269497b..6e8273e9 100644 --- a/public_html/js/Util.js +++ b/public_html/js/Util.js @@ -41,7 +41,7 @@ App.Util = (function(jQuery, promise) { var initResult = presenter.init.call(presenter, args); lastContentPresenterName = presenterName; lastContentPresenter = presenter; - } else { + } else if (lastContentPresenter.reinit) { lastContentPresenter.reinit.call(presenter, args); } } diff --git a/public_html/templates/login-form.tpl b/public_html/templates/login-form.tpl index 2f4ae247..9a50749e 100644 --- a/public_html/templates/login-form.tpl +++ b/public_html/templates/login-form.tpl @@ -38,7 +38,7 @@

Problems logging in?

diff --git a/public_html/templates/top-navigation.tpl b/public_html/templates/top-navigation.tpl index 642b0bb5..26652ec0 100644 --- a/public_html/templates/top-navigation.tpl +++ b/public_html/templates/top-navigation.tpl @@ -1,10 +1,34 @@ diff --git a/src/Privilege.php b/src/Privilege.php index 2ad06147..c2b107fd 100644 --- a/src/Privilege.php +++ b/src/Privilege.php @@ -17,4 +17,11 @@ class Privilege const CHANGE_ALL_PASSWORDS = 'changeAllPasswords'; const DELETE_OWN_ACCOUNT = 'deleteOwnAccount'; const DELETE_ALL_ACCOUNTS = 'deleteAllAccounts'; + + const LIST_SAFE_POSTS = 'listSafePosts'; + const LIST_SKETCHY_POSTS = 'listSketchyPosts'; + const LIST_UNSAFE_POSTS = 'listUnsafePosts'; + const UPLOAD_POSTS = 'uploadPosts'; + + const LIST_TAGS = 'listTags'; }