BryanDavis has uploaded a new change for review.
https://gerrit.wikimedia.org/r/218997
Change subject: Campaign selection cleanup
......................................................................
Campaign selection cleanup
* Remove index page template and controller
* Redirect /index to /campaigns
* Split up navigation for reuse via includes
* Display campaigns as a list rather than separate divs
Change-Id: I61ff1519443af2c7678978d656bb910c13e2cc9c
---
M data/i18n/en.json
M data/i18n/qqq.json
M data/templates/admin/base.html
M data/templates/base.html
M data/templates/campaign.html
D data/templates/index.html
M data/templates/login.html
A data/templates/nav_basic.html
A data/templates/nav_login.html
M data/templates/nav_user.html
M data/templates/user/base.html
M src/App.php
D src/Controllers/Index.php
13 files changed, 116 insertions(+), 204 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/iegreview
refs/changes/97/218997/1
diff --git a/data/i18n/en.json b/data/i18n/en.json
index 820c916..6aabc7b 100644
--- a/data/i18n/en.json
+++ b/data/i18n/en.json
@@ -29,8 +29,6 @@
"new-account-subject": "New grants review account",
"new-account-email": "A new grants review account has been created for
you.\n\nYour login info is:\n\nusername: $1\npassword: $2\n\nYou may login at:
$3\n\nYou may change your password at: $4\n\nSincerely,\nGrants review
administrators",
- "index-page": "Welcome to the Wikimedia grants review application.",
-
"credits": "Credits & licensing",
"credits-page-license": "The Wikimedia grants review software is open
source and <a
href=\"//git.wikimedia.org/log/wikimedia%2Fiegreview\">available</a> under the
<a href=\"http://www.gnu.org/copyleft/gpl.html\">GNU General Public License
3.0</a>.",
"credits-page-scholarships": "The application is based on code
developed for the <a
href=\"https://git.wikimedia.org/log/wikimedia%2Fwikimania-scholarships\">Wikimania
Scholarships application</a>.",
@@ -132,9 +130,11 @@
"admin-proposal-theme": "Theme",
"admin-proposal-amount": "Amount",
- "campaigns-welcome": "Welcome reviewer! Pick a campaign to start
reviewing.",
+ "campaigns-welcome": "Welcome to the Wikimedia grants review
application.",
"campaigns-active": "Active campaigns",
+ "campaigns-active-empty": "No active campaigns found",
"campaigns-past": "Past campaigns",
+ "campaigns-past-empty": "No past campaigns found",
"page-of-pages": "Page $1 of $2",
"no-results": "No results found",
diff --git a/data/i18n/qqq.json b/data/i18n/qqq.json
index 0ba6cd4..72688c4 100644
--- a/data/i18n/qqq.json
+++ b/data/i18n/qqq.json
@@ -67,7 +67,9 @@
"campaigns-welcome": "Welcome message for reviewer landing page",
"campaigns-active": "Active campaigns header",
+ "campaigns-active-empty": "Replacement for empty campaign list",
"campaigns-past": "Past campaigns header",
+ "campaigns-past-empty": "Replacement for empty campaign list",
"change-password": "Navigation menu item, links to password change
page.\n{{Identical|Change password}}",
"credits": "Credits page heading",
@@ -87,7 +89,6 @@
"form-no": "Radio button label.",
"form-yes": "Radio button label.",
"header-title": "Used as the page title",
- "index-page": "Landing page content,\n\nProcessed as wikitext.",
"login": "Login page heading and label for form submit
button.\n{{Identical|Log in}}",
"login-error": "Message shown to user when authentication form is
submitted with incomplete data",
"login-failed": "Message shown to user when authentication fails",
diff --git a/data/templates/admin/base.html b/data/templates/admin/base.html
index 375c888..5076c4f 100644
--- a/data/templates/admin/base.html
+++ b/data/templates/admin/base.html
@@ -1,36 +1,6 @@
{% extends "base.html" %}
{% block title %}{% block subtitle %}{% endblock subtitle %} - {{ parent()
}}{% endblock title %}
+
{% block navbar %}
-<ul class="nav navbar-nav">
-
-<li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{
'nav-campaigns'|message }} <b class="caret"></b></a>
- <ul class="dropdown-menu">
- {% for c in listcampaigns %}
- <li><a href="{{ urlFor( 'proposals_queue', { 'campaign':c.id } ) }}">{{
c.name }}</a></li>
- {% endfor %}
- </ul>
-</li>
-
-{% if isadmin|default(false) %}
-<li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{
'nav-admin'|message }} <b class="caret"></b></a>
- <ul class="dropdown-menu">
- <li><a href="{{ urlFor( 'admin_users' ) }}">{{ 'nav-users'|message
}}</a></li>
- <li><a href="{{ urlFor( 'admin_user', { 'id':'new' } ) }}">{{
'admin-users-add'|message }}</a></li>
- <li><a href="{{ urlFor( 'admin_campaigns' ) }}">{{
'admin-campaign-manage'|message }}</a></li>
- <li><a href="{{ urlFor( 'admin_campaign', { 'id':'new' } ) }}">{{
'admin-campaign-add'|message }}</a></li>
- </ul>
-</li>
-{% endif %}
-
-<li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{
'nav-account'|message }} <b class="caret"></b></a>
- <ul class="dropdown-menu">
- <li><a href="{{ urlFor( 'user_changepassword' ) }}">{{
'change-password'|message }}</a></li>
- <li><a href="{{ urlFor( 'logout' ) }}">{{ 'logout'|message }}</a></li>
- </ul>
-</li>
-
-</ul>
-{% endblock navbar %}
\ No newline at end of file
+{% include 'nav_basic.html' %}
+{% endblock navbar %}
diff --git a/data/templates/base.html b/data/templates/base.html
index 510a062..fe3dd27 100644
--- a/data/templates/base.html
+++ b/data/templates/base.html
@@ -28,28 +28,15 @@
<a class="navbar-brand" href="{{ urlFor( 'campaigns') }}" title="{{
'header-title'|message }}"><img src="{{ siteUrl( 'images/glasses.png' ) }}"
width="46" height="36" alt="{{ 'logo-alt'|message }}"></a>
</div>
<div class="navbar-collapse collapse">
+ <ul class="nav navbar-nav">
{% block navbar %}
{% if user|default(false) %}
{% include 'nav_user.html' %}
{% else %}
- <ul class="nav navbar-nav">
- {% block login_form %}
- <form class="navbar-form navbar-right" action="{{ urlFor(
'login_post' ) }}" method="post" role="form">
- <input type="hidden" name="{{ csrf_param }}" value="{{
csrf_token }}" />
- <div class="form-group">
- <label for="username" class="sr-only control-label">{{
'username'|message }}</label>
- <input type="text" class="form-control" id="username"
name="username" required="required" placeholder="{{ 'username'|message }}"/>
- </div>
- <div class="form-group">
- <label for="password" class="sr-only control-label">{{
'password'|message }}</label>
- <input type="password" class="form-control" id="password"
name="password" required="required" placeholder="{{ 'password'|message }}"/>
- </div>
- <input type="submit" class="btn btn-default" value="{{
'login'|message }}" />
- </form>
- {% endblock login_form %}
- </ul>
+ {% include 'nav_login.html' %}
{% endif %}
{% endblock navbar %}
+ </ul>
<div class="navbar-right navbar-text form-inline">
{% if i18nCtx.getAvailableLanguages|length > 1 %}
<span class="langlabel">{{ 'nav-language'|message }}</span>
diff --git a/data/templates/campaign.html b/data/templates/campaign.html
index e6acefe..d3885de 100644
--- a/data/templates/campaign.html
+++ b/data/templates/campaign.html
@@ -1,41 +1,53 @@
{% extends "base.html" %}
-{% block navbar %}{% endblock navbar %}
+
+{% block navbar %}
+{% if user|default(false) %}
+{% include 'nav_basic.html' %}
+{% else %}
+{% include 'nav_login.html' %}
+{% endif %}
+{% endblock navbar %}
{% block content %}
{% spaceless %}
<div class="row">
<div class="col-md-10 col-md-offset-1">
- <h2>{{ 'campaigns-welcome'|message }}</h2>
+ <h2>{{ 'header-title'|message }}</h2>
+ <p>{{ 'campaigns-welcome'|message }}</p>
</div>
</div>
+
{% if user|default(false) %}
+<div class="row">
+ <div class="col-md-10 col-md-offset-1">
+ <h3>{{ 'campaigns-active'|message }}</h3>
+ <ul>
+ {% for campaign in campaigns if campaign.status == 1 %}
+ <li>
+ <a href ="{{ urlFor( 'proposals_home', { 'campaign':campaign.id } )
}}" >{{ campaign.name }}</a>
+ </li>
+ {% else %}
+ <li>{{ 'campaigns-active-empty'|message }} </li>
+ {% endfor %}
+ </ul>
+ </div>
+</div>
+
<div class="row">
<div class="col-md-10 col-md-offset-1">
- <h3>{{ 'campaigns-active'|message }}</h3>
+ <h3>{{ 'campaigns-past'|message }}</h3>
+ <ul>
+ {% for campaign in campaigns if campaign.status == 0 %}
+ <li>
+ <a href ="{{ urlFor( 'proposals_home', { 'campaign':campaign.id } )
}}" >{{ campaign.name }}</a>
+ </li>
+ {% else %}
+ <li>{{ 'campaigns-past-empty'|message }} </li>
+ {% endfor %}
+ </ul>
</div>
</div>
- {% for campaign in campaigns if campaign.status == 1 %}
- <div class="row">
- <div class="col-md-10 col-md-offset-1">
- <a href ="{{ urlFor( 'proposals_home', { 'campaign':campaign.id } )
}}" >{{ campaign.name }}</a>
- </div>
- </div>
- {% endfor %}
-<div class="row">
- <div class="col-md-10 col-md-offset-1">
- <h3>{{ 'campaigns-past'|message }}</h3>
- </div>
-</div>
- {% for campaign in campaigns if campaign.status == 0 %}
- <div class="row">
- <div class="col-md-10 col-md-offset-1">
- <a href ="{{ urlFor( 'proposals_home', { 'campaign':campaign.id } )
}}" >{{ campaign.name }}</a>
- </div>
- </div>
- {% endfor %}
-
{% endif %}
-
{% endspaceless %}
-{% endblock content %}
\ No newline at end of file
+{% endblock content %}
diff --git a/data/templates/index.html b/data/templates/index.html
deleted file mode 100644
index cbd9f5d..0000000
--- a/data/templates/index.html
+++ /dev/null
@@ -1,13 +0,0 @@
-{% extends "base.html" %}
-
-{% block content %}
-{% spaceless %}
-<div class="row">
- <div class="col-md-10 col-md-offset-1">
- <h2>{{ 'header-title'|message }}</h2>
- {{ 'index-page'|message|raw|wikitext }}
- </div>
-</div>
-
-{% endspaceless %}
-{% endblock content %}
diff --git a/data/templates/login.html b/data/templates/login.html
index c417f5f..5b57270 100644
--- a/data/templates/login.html
+++ b/data/templates/login.html
@@ -2,7 +2,7 @@
{% block title %}{{ 'login'|message }} - {{ parent() }}{% endblock title %}
-{% block login_form %}{% endblock %}
+{% block navbar %}{% endblock %}
{% block content %}
{% spaceless %}
diff --git a/data/templates/nav_basic.html b/data/templates/nav_basic.html
new file mode 100644
index 0000000..66ef944
--- /dev/null
+++ b/data/templates/nav_basic.html
@@ -0,0 +1,31 @@
+{% if listcampaigns|default(false) %}
+<li class="dropdown">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{
'nav-campaigns'|message }} <b class="caret"></b></a>
+ <ul class="dropdown-menu">
+ {% for c in listcampaigns %}
+ <li><a href="{{ urlFor( 'proposals_queue', { 'campaign':c.id } ) }}">{{
c.name }}</a></li>
+ {% endfor %}
+ </ul>
+</li>
+{% endif %}
+
+{% if isadmin|default(false) %}
+<li class="dropdown">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{
'nav-admin'|message }} <b class="caret"></b></a>
+ <ul class="dropdown-menu">
+ <li><a href="{{ urlFor( 'admin_users' ) }}">{{ 'nav-users'|message
}}</a></li>
+ <li><a href="{{ urlFor( 'admin_user', { 'id':'new' } ) }}">{{
'admin-users-add'|message }}</a></li>
+ <li><a href="{{ urlFor( 'admin_campaigns' ) }}">{{
'admin-campaign-manage'|message }}</a></li>
+ <li><a href="{{ urlFor( 'admin_campaign', { 'id':'new' } ) }}">{{
'admin-campaign-add'|message }}</a></li>
+ </ul>
+</li>
+{% endif %}
+
+<li class="dropdown">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{
'nav-account'|message }} <b class="caret"></b></a>
+ <ul class="dropdown-menu">
+ <li><a href="{{ urlFor( 'user_changepassword' ) }}">{{
'change-password'|message }}</a></li>
+ <li><a href="{{ urlFor( 'user_manageaccount' ) }}">{{
'manage-account'|message }}</a></li>
+ <li><a href="{{ urlFor( 'logout' ) }}">{{ 'logout'|message }}</a></li>
+ </ul>
+</li>
diff --git a/data/templates/nav_login.html b/data/templates/nav_login.html
new file mode 100644
index 0000000..d3a3579
--- /dev/null
+++ b/data/templates/nav_login.html
@@ -0,0 +1,14 @@
+{% block login_form %}
+<form class="navbar-form navbar-right" action="{{ urlFor( 'login_post' ) }}"
method="post" role="form">
+ <input type="hidden" name="{{ csrf_param }}" value="{{ csrf_token }}" />
+ <div class="form-group">
+ <label for="username" class="sr-only control-label">{{ 'username'|message
}}</label>
+ <input type="text" class="form-control" id="username" name="username"
required="required" placeholder="{{ 'username'|message }}"/>
+ </div>
+ <div class="form-group">
+ <label for="password" class="sr-only control-label">{{ 'password'|message
}}</label>
+ <input type="password" class="form-control" id="password" name="password"
required="required" placeholder="{{ 'password'|message }}"/>
+ </div>
+ <input type="submit" class="btn btn-default" value="{{ 'login'|message }}" />
+</form>
+{% endblock login_form %}
diff --git a/data/templates/nav_user.html b/data/templates/nav_user.html
index 0096223..846cb12 100644
--- a/data/templates/nav_user.html
+++ b/data/templates/nav_user.html
@@ -1,4 +1,3 @@
-<ul class="nav navbar-nav">
{% if isreviewer|default(false) or isadmin|default(false) %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{
'nav-proposals'|message }} <b class="caret"></b></a>
@@ -25,26 +24,4 @@
</li>
{% endif %}
-{% if isadmin|default(false) %}
-<li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{
'nav-admin'|message }} <b class="caret"></b></a>
- <ul class="dropdown-menu">
- <li><a href="{{ urlFor( 'admin_users' ) }}">{{ 'nav-users'|message
}}</a></li>
- <li><a href="{{ urlFor( 'admin_user', { 'id':'new' } ) }}">{{
'admin-users-add'|message }}</a></li>
- <li><a href="{{ urlFor( 'admin_campaigns' ) }}">{{
'admin-campaign-manage'|message }}</a></li>
- <li><a href="{{ urlFor( 'admin_campaign', { 'id':'new' } ) }}">{{
'admin-campaign-add'|message }}</a></li>
- </ul>
-</li>
-{% endif %}
-
-<li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{
'nav-account'|message }} <b class="caret"></b></a>
- <ul class="dropdown-menu">
- <li><a href="{{ urlFor( 'user_changepassword' ) }}">{{
'change-password'|message }}</a></li>
- <li><a href="{{ urlFor( 'user_manageaccount' ) }}">{{
'manage-account'|message }}</a></li>
- <li><a href="{{ urlFor( 'logout' ) }}">{{ 'logout'|message }}</a></li>
- </ul>
-</li>
-
-</ul>
-
+{% include 'nav_basic.html' %}
diff --git a/data/templates/user/base.html b/data/templates/user/base.html
index 933d40c..5076c4f 100644
--- a/data/templates/user/base.html
+++ b/data/templates/user/base.html
@@ -2,36 +2,5 @@
{% block title %}{% block subtitle %}{% endblock subtitle %} - {{ parent()
}}{% endblock title %}
{% block navbar %}
-<ul class="nav navbar-nav">
-
-<li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{
'nav-campaigns'|message }} <b class="caret"></b></a>
- <ul class="dropdown-menu">
- {% for c in listcampaigns %}
- <li><a href="{{ urlFor( 'proposals_queue', { 'campaign':c.id } ) }}">{{
c.name }}</a></li>
- {% endfor %}
- </ul>
-</li>
-
-{% if isadmin|default(false) %}
-<li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{
'nav-admin'|message }} <b class="caret"></b></a>
- <ul class="dropdown-menu">
- <li><a href="{{ urlFor( 'admin_users' ) }}">{{ 'nav-users'|message
}}</a></li>
- <li><a href="{{ urlFor( 'admin_user', { 'id':'new' } ) }}">{{
'admin-users-add'|message }}</a></li>
- <li><a href="{{ urlFor( 'admin_campaigns' ) }}">{{
'admin-campaign-manage'|message }}</a></li>
- <li><a href="{{ urlFor( 'admin_campaign', { 'id':'new' } ) }}">{{
'admin-campaign-add'|message }}</a></li>
- </ul>
-</li>
-{% endif %}
-
-<li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{
'nav-account'|message }} <b class="caret"></b></a>
- <ul class="dropdown-menu">
- <li><a href="{{ urlFor( 'user_changepassword' ) }}">{{
'change-password'|message }}</a></li>
- <li><a href="{{ urlFor( 'logout' ) }}">{{ 'logout'|message }}</a></li>
- </ul>
-</li>
-
-</ul>
-{% endblock navbar %}
\ No newline at end of file
+{% include 'nav_basic.html' %}
+{% endblock navbar %}
diff --git a/src/App.php b/src/App.php
index 1bb50c8..ea950e8 100644
--- a/src/App.php
+++ b/src/App.php
@@ -405,10 +405,8 @@
$slim->group( '/',
$middleware['inject-user'],
function () use ( $slim, $middleware ) {
- $slim->get( '', function () use ( $slim ) {
- $slim->flashKeep();
- $slim->redirect( $slim->urlFor(
'campaigns' ) );
- } )->name( 'home' );
+ App::redirect( $slim, '', 'campaigns', 'home' );
+ App::redirect( $slim, 'index', 'campaigns' );
$slim->get( 'campaigns',
$middleware['must-revalidate'],
function () use ( $slim ) {
@@ -417,12 +415,6 @@
$page();
}
)->name( 'campaigns' );
-
- $slim->get( 'index', function () use ( $slim ) {
- $page = new Controllers\Index( $slim );
- $page->setDao( $slim->campaignsDao );
- $page();
- } )->name( 'index' );
App::template( $slim, 'credits' );
App::template( $slim, 'privacy' );
@@ -653,6 +645,23 @@
/**
+ * Add a redirect route to the app.
+ * @param \Slim\Slim $slim App
+ * @param string $name Page name
+ * @param string $to Redirect target route name
+ * @param string $routeName Name for the route
+ */
+ public static function redirect( $slim, $name, $to, $routeName = null )
{
+ $routeName = $routeName ?: $name;
+
+ $slim->get( $name, function () use ( $slim, $name, $to ) {
+ $slim->flashKeep();
+ $slim->redirect( $slim->urlFor( $to ) );
+ } )->name( $routeName );
+ }
+
+
+ /**
* Add a static template route to the app.
* @param \Slim\Slim $slim App
* @param string $name Page name
diff --git a/src/Controllers/Index.php b/src/Controllers/Index.php
deleted file mode 100644
index 2b618da..0000000
--- a/src/Controllers/Index.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-/**
- * @section LICENSE
- * This file is part of Wikimedia Grants Review application.
- *
- * Wikimedia Grants Review application is free software: you can
- * redistribute it and/or modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Wikimedia Grants Review application is distributed in the hope that it
- * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with Wikimedia Grants Review application. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * @file
- * @copyright © 2015 Niharika Kohli, Wikimedia Foundation and contributors.
- */
-
-namespace Wikimedia\IEGReview\Controllers;
-
-use Wikimedia\IEGReview\AuthManager;
-use Wikimedia\IEGReview\Controller;
-
-/**
- * Routes related to authentication.
- *
- * @author Niharika Kohli <[email protected]>
- * @copyright © 2015 Niharika Kohli, Wikimedia Foundation and contributors.
- */
-class Index extends Controller {
-
- protected function handleGet() {
- $this->render( 'index.html' );
- }
-
- protected function handlePost() {
- $this->redirect( $this->urlFor( 'login' ) );
- }
-
-}
--
To view, visit https://gerrit.wikimedia.org/r/218997
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I61ff1519443af2c7678978d656bb910c13e2cc9c
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/iegreview
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits