Add proper table sorting and add some security headers

This commit is contained in:
Timothy Warren 2016-01-20 13:01:41 -05:00
parent e59ead5a84
commit daf4b71bbb
11 changed files with 62 additions and 1168 deletions

View File

@ -15,9 +15,7 @@ script:
- phpunit -c build - phpunit -c build
after_script: after_script:
- wget https://scrutinizer-ci.com/ocular.phar - CODECLIMATE_REPO_TOKEN=2cbddcebcb9256b3402867282e119dbe61de0b31039325356af3c7d72ed6d058 vendor/bin/test-reporter
- php ocular.phar code-coverage:upload --format=php-clover build/logs/coverage.clover
- CODECLIMATE_REPO_TOKEN=2cbddcebcb9256b3402867282e119dbe61de0b31039325356af3c7d72ed6d058 vendor/bin/test-reporter
matrix: matrix:
allow_failures: allow_failures:

View File

@ -27,19 +27,19 @@ return [
*/ */
'table' => [ 'table' => [
'lib/jquery.min.js', 'lib/jquery.min.js',
'lib/table_sorter/jquery.tablesorter.min.js', 'lib/datatables.js',
'sort_tables.js' 'sort_tables.js'
], ],
'edit' => [ 'table_edit' => [
'lib/jquery.min.js', 'lib/jquery.min.js',
'lib/datatables.js',
'sort_tables.js',
'show_message.js', 'show_message.js',
'anime_edit.js', 'anime_edit.js',
'manga_edit.js' 'manga_edit.js'
], ],
'table_edit' => [ 'edit' => [
'lib/jquery.min.js', 'lib/jquery.min.js',
'lib/table_sorter/jquery.tablesorter.min.js',
'sort_tables.js',
'show_message.js', 'show_message.js',
'anime_edit.js', 'anime_edit.js',
'manga_edit.js' 'manga_edit.js'

View File

@ -4,6 +4,8 @@
<head> <head>
<title><?= $title ?></title> <title><?= $title ?></title>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta http-equiv="cache-control" content="no-store" />
<meta http-equiv="Content-Security-Policy" content="script-src self" />
<link rel="stylesheet" href="<?= $urlGenerator->asset_url('css.php?g=base') ?>" /> <link rel="stylesheet" href="<?= $urlGenerator->asset_url('css.php?g=base') ?>" />
<script> <script>
var BASE_URL = "<?= $urlGenerator->base_url($url_type) ?>"; var BASE_URL = "<?= $urlGenerator->base_url($url_type) ?>";

View File

@ -20,6 +20,20 @@ tbody > tr:nth-child(odd) {
background: #ddd; background: #ddd;
} }
/* Table sorting styles */
th.sorting::after {
content: " ↕ ";
}
th.sorting_asc::after {
content: " ↑ ";
}
th.sorting_desc::after {
content: " ↓ ";
}
input[type=number] { input[type=number] {
width: 4em; width: 4em;
} }

View File

@ -26,6 +26,17 @@ tbody > tr:nth-child(odd) {
background: #ddd; background: #ddd;
} }
/* Table sorting styles */
th.sorting::after {
content: " ↕ ";
}
th.sorting_asc::after {
content: " ↑ ";
}
th.sorting_desc::after {
content: " ↓ ";
}
input[type=number] { input[type=number] {
width: 4em; width: 4em;
} }

View File

@ -1,122 +0,0 @@
/*
* Metadata - jQuery plugin for parsing metadata from elements
*
* Copyright (c) 2006 John Resig, Yehuda Katz, J<EFBFBD>örn Zaefferer, Paul McLanahan
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Revision: $Id$
*
*/
/**
* Sets the type of metadata to use. Metadata is encoded in JSON, and each property
* in the JSON will become a property of the element itself.
*
* There are three supported types of metadata storage:
*
* attr: Inside an attribute. The name parameter indicates *which* attribute.
*
* class: Inside the class attribute, wrapped in curly braces: { }
*
* elem: Inside a child element (e.g. a script tag). The
* name parameter indicates *which* element.
*
* The metadata for an element is loaded the first time the element is accessed via jQuery.
*
* As a result, you can define the metadata type, use $(expr) to load the metadata into the elements
* matched by expr, then redefine the metadata type and run another $(expr) for other elements.
*
* @name $.metadata.setType
*
* @example <p id="one" class="some_class {item_id: 1, item_label: 'Label'}">This is a p</p>
* @before $.metadata.setType("class")
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
* @desc Reads metadata from the class attribute
*
* @example <p id="one" class="some_class" data="{item_id: 1, item_label: 'Label'}">This is a p</p>
* @before $.metadata.setType("attr", "data")
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
* @desc Reads metadata from a "data" attribute
*
* @example <p id="one" class="some_class"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>
* @before $.metadata.setType("elem", "script")
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
* @desc Reads metadata from a nested script element
*
* @param String type The encoding type
* @param String name The name of the attribute to be used to get metadata (optional)
* @cat Plugins/Metadata
* @descr Sets the type of encoding to be used when loading metadata for the first time
* @type undefined
* @see metadata()
*/
(function($) {
$.extend({
metadata : {
defaults : {
type: 'class',
name: 'metadata',
cre: /({.*})/,
single: 'metadata'
},
setType: function( type, name ){
this.defaults.type = type;
this.defaults.name = name;
},
get: function( elem, opts ){
var settings = $.extend({},this.defaults,opts);
// check for empty string in single property
if ( !settings.single.length ) settings.single = 'metadata';
var data = $.data(elem, settings.single);
// returned cached data if it already exists
if ( data ) return data;
data = "{}";
if ( settings.type == "class" ) {
var m = settings.cre.exec( elem.className );
if ( m )
data = m[1];
} else if ( settings.type == "elem" ) {
if( !elem.getElementsByTagName )
return undefined;
var e = elem.getElementsByTagName(settings.name);
if ( e.length )
data = $.trim(e[0].innerHTML);
} else if ( elem.getAttribute != undefined ) {
var attr = elem.getAttribute( settings.name );
if ( attr )
data = attr;
}
if ( data.indexOf( '{' ) <0 )
data = "{" + data + "}";
data = eval("(" + data + ")");
$.data( elem, settings.single, data );
return data;
}
}
});
/**
* Returns the metadata object for the first member of the jQuery object.
*
* @name metadata
* @descr Returns element's metadata object
* @param Object opts An object contianing settings to override the defaults
* @type jQuery
* @cat Plugins/Metadata
*/
$.fn.metadata = function( opts ){
return $.metadata.get( this[0], opts );
};
})(jQuery);

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,8 @@
$(function() {
$('table').tablesorter(); $('table').DataTable({
}); paging: false,
searching: false,
language: {
info: ""
}
});

View File

@ -255,5 +255,21 @@ class Anime extends BaseController {
) )
); );
} }
/**
* View details of an anime
*
* @param string anime_id
* @return void
*/
public function details($anime_id)
{
$data = $this->model->get_anime($anime_id);
$this->outputHTML('anime/details', [
'title' => $data['title'],
'data' => $data,
]);
}
} }
// End of AnimeController.php // End of AnimeController.php

View File

@ -65,6 +65,11 @@ class HttpView extends BaseView {
*/ */
protected function output() protected function output()
{ {
$this->response->headers->set('Content-Security-Policy', 'script-src self');
$this->response->headers->set('X-Content-Type-Options', 'nosniff');
$this->response->headers->set('X-XSS-Protection', '1;mode=block');
$this->response->headers->set('X-Frame-Options', 'SAMEORIGIN');
$content =& $this->response->content; $content =& $this->response->content;
$content->set($this->output); $content->set($this->output);
$content->setType($this->contentType); $content->setType($this->contentType);