Merge branch 'composer-new' of git://github.com/DakuTree/shimmie2 into DakuTree-composer-new
This commit is contained in:
commit
15076f4981
6 changed files with 88 additions and 76 deletions
|
@ -13,15 +13,27 @@ class AutoComplete extends Extension {
|
||||||
if(!isset($_GET["s"])) return;
|
if(!isset($_GET["s"])) return;
|
||||||
|
|
||||||
//$limit = 0;
|
//$limit = 0;
|
||||||
|
$cache_key = "autocomplete-" . strtolower($_GET["s"]);
|
||||||
$limitSQL = "";
|
$limitSQL = "";
|
||||||
$SQLarr = array("search"=>$_GET["s"]."%");
|
$SQLarr = array("search"=>$_GET["s"]."%");
|
||||||
if(isset($_GET["limit"]) && $_GET["limit"] !== 0){
|
if(isset($_GET["limit"]) && $_GET["limit"] !== 0){
|
||||||
$limitSQL = "LIMIT :limit";
|
$limitSQL = "LIMIT :limit";
|
||||||
$SQLarr['limit'] = $_GET["limit"];
|
$SQLarr['limit'] = $_GET["limit"];
|
||||||
|
$cache_key .= "-" . $_GET["limit"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $database->get_col(
|
$res = $database->cache->get($cache_key);
|
||||||
"SELECT tag FROM tags WHERE tag LIKE :search AND count > 0 $limitSQL", $SQLarr);
|
if(!$res) {
|
||||||
|
$res = $database->get_pairs($database->scoreql_to_sql("
|
||||||
|
SELECT tag, count
|
||||||
|
FROM tags
|
||||||
|
WHERE SCORE_STRNORM(tag) LIKE SCORE_STRNORM(:search)
|
||||||
|
AND count > 0
|
||||||
|
ORDER BY count DESC
|
||||||
|
$limitSQL"), $SQLarr
|
||||||
|
);
|
||||||
|
$database->cache->set($cache_key, $res, 600);
|
||||||
|
}
|
||||||
|
|
||||||
$page->set_mode("data");
|
$page->set_mode("data");
|
||||||
$page->set_type("application/json");
|
$page->set_type("application/json");
|
||||||
|
|
58
ext/autocomplete/script.js
Normal file
58
ext/autocomplete/script.js
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
$(function(){
|
||||||
|
$('[name=search]').tagit({
|
||||||
|
singleFieldDelimiter: ' ',
|
||||||
|
beforeTagAdded: function(event, ui) {
|
||||||
|
// give special class to negative tags
|
||||||
|
if(ui.tagLabel[0] === '-') {
|
||||||
|
ui.tag.addClass('tag-negative');
|
||||||
|
}else{
|
||||||
|
ui.tag.addClass('tag-positive');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
autocomplete : ({
|
||||||
|
source: function (request, response) {
|
||||||
|
var isNegative = (request.term[0] === '-');
|
||||||
|
$.ajax({
|
||||||
|
url: base_href + '/api/internal/autocomplete',
|
||||||
|
data: {'s': (isNegative ? request.term.substring(1) : request.term)},
|
||||||
|
dataType : 'json',
|
||||||
|
type : 'GET',
|
||||||
|
success : function (data) {
|
||||||
|
response($.map(data, function (count, item) {
|
||||||
|
item = (isNegative ? '-'+item : item);
|
||||||
|
return {
|
||||||
|
label : item + ' ('+count+')',
|
||||||
|
value : item
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
error : function (request, status, error) {
|
||||||
|
alert(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
minLength: 1
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.ui-autocomplete-input').keydown(function(e) {
|
||||||
|
var keyCode = e.keyCode || e.which;
|
||||||
|
|
||||||
|
//Stop tags containing space.
|
||||||
|
if(keyCode == 32) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
$('[name=search]').tagit('createTag', $(this).val());
|
||||||
|
$(this).autocomplete('close');
|
||||||
|
} else if (keyCode == 9) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
var tag = $('.tagit-autocomplete[style*=\"display: block\"] > li:first').text();
|
||||||
|
if(tag){
|
||||||
|
$('[name=search]').tagit('createTag', tag);
|
||||||
|
$('.ui-autocomplete-input').autocomplete('close');
|
||||||
|
$('.ui-autocomplete-input').val(''); //If tag already exists, make sure to remove duplicate.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
.tagit { background: white !important; border: 1px solid grey !important; cursor: text; }
|
.tagit { background: white !important; border: 1px solid grey !important; cursor: text; }
|
||||||
.tagit-choice { cursor: initial; }
|
.tagit-choice { cursor: initial; }
|
||||||
input[name=search] ~ input[type=submit] { display: block !important; }
|
input[name=search] ~ input[type=submit] { display: inline-block !important; }
|
||||||
|
|
||||||
.tag-negative { background: #ff8080 !important; }
|
.tag-negative { background: #ff8080 !important; }
|
||||||
.tag-positive { background: #40bf40 !important; }
|
.tag-positive { background: #40bf40 !important; }
|
|
@ -7,68 +7,7 @@ class AutoCompleteTheme extends Themelet {
|
||||||
|
|
||||||
$page->add_html_header("<script src='$base_href/ext/autocomplete/lib/jquery-ui.min.js' type='text/javascript'></script>");
|
$page->add_html_header("<script src='$base_href/ext/autocomplete/lib/jquery-ui.min.js' type='text/javascript'></script>");
|
||||||
$page->add_html_header("<script src='$base_href/ext/autocomplete/lib/tag-it.min.js' type='text/javascript'></script>");
|
$page->add_html_header("<script src='$base_href/ext/autocomplete/lib/tag-it.min.js' type='text/javascript'></script>");
|
||||||
$page->add_html_header('<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/flick/jquery-ui.css">');
|
$page->add_html_header('<link rel="stylesheet" type="text/css" href="//ajax.googleapis.com/ajax/libs/jqueryui/1/themes/flick/jquery-ui.css">');
|
||||||
$page->add_html_header("<link rel='stylesheet' type='text/css' href='$base_href/ext/autocomplete/lib/jquery.tagit.css' />");
|
$page->add_html_header("<link rel='stylesheet' type='text/css' href='$base_href/ext/autocomplete/lib/jquery.tagit.css' />");
|
||||||
|
|
||||||
$page->add_html_header("<script>
|
|
||||||
$(function(){
|
|
||||||
$('[name=search]').tagit({
|
|
||||||
singleFieldDelimiter: ' ',
|
|
||||||
beforeTagAdded: function(event, ui) {
|
|
||||||
// give special class to negative tags
|
|
||||||
if(ui.tagLabel[0] === '-') {
|
|
||||||
ui.tag.addClass('tag-negative');
|
|
||||||
}else{
|
|
||||||
ui.tag.addClass('tag-positive');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
autocomplete : ({
|
|
||||||
source: function (request, response) {
|
|
||||||
var isNegative = (request.term[0] === '-');
|
|
||||||
$.ajax({
|
|
||||||
url: base_href + '/api/internal/autocomplete',
|
|
||||||
data: {'s': (isNegative ? request.term.substring(1) : request.term)},
|
|
||||||
dataType : 'json',
|
|
||||||
type : 'GET',
|
|
||||||
success : function (data) {
|
|
||||||
response($.map(data, function (item) {
|
|
||||||
item = (isNegative ? '-'+item : item);
|
|
||||||
return {
|
|
||||||
label : item,
|
|
||||||
value : item
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
error : function (request, status, error) {
|
|
||||||
alert(error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
minLength: 1
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.ui-autocomplete-input').keydown(function(e) {
|
|
||||||
var keyCode = e.keyCode || e.which;
|
|
||||||
|
|
||||||
//Stop tags containing space.
|
|
||||||
if(keyCode == 32) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
$('[name=search]').tagit('createTag', $(this).val());
|
|
||||||
$(this).autocomplete('close');
|
|
||||||
} else if (keyCode == 9) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
var tag = $('.tagit-autocomplete[style*=\"display: block\"] > li:first').text();
|
|
||||||
if(tag){
|
|
||||||
$('[name=search]').tagit('createTag', tag);
|
|
||||||
$('.ui-autocomplete-input').autocomplete('close');
|
|
||||||
$('.ui-autocomplete-input').val(''); //If tag already exists, make sure to remove duplicate.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
ext/home/style.css
Normal file
13
ext/home/style.css
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
div#front-page h1 {font-size: 4em; margin-top: 2em; margin-bottom: 0px; text-align: center; border: none; background: none; box-shadow: none; -webkit-box-shadow: none; -moz-box-shadow: none;}
|
||||||
|
div#front-page {text-align:center;}
|
||||||
|
.space {margin-bottom: 1em;}
|
||||||
|
div#front-page div#links a {margin: 0 0.5em;}
|
||||||
|
div#front-page li {list-style-type: none; margin: 0;}
|
||||||
|
@media (max-width: 800px) {
|
||||||
|
div#front-page h1 {font-size: 3em; margin-top: 0.5em; margin-bottom: 0.5em;}
|
||||||
|
#counter {display: none;}
|
||||||
|
}
|
||||||
|
|
||||||
|
div#front-page > #search > form { margin: 0 auto; }
|
||||||
|
div#front-page > #search > form > ul { width: 225px; vertical-align: middle; display: inline-block; }
|
||||||
|
div#front-page > #search > form > input[type=submit]{ padding: 4px 6px; }
|
|
@ -5,6 +5,7 @@ class HomeTheme extends Themelet {
|
||||||
$page->set_mode("data");
|
$page->set_mode("data");
|
||||||
$hh = "";
|
$hh = "";
|
||||||
$page->add_auto_html_headers();
|
$page->add_auto_html_headers();
|
||||||
|
ksort($page->html_headers);
|
||||||
foreach($page->html_headers as $h) {$hh .= $h;}
|
foreach($page->html_headers as $h) {$hh .= $h;}
|
||||||
$page->set_data(<<<EOD
|
$page->set_data(<<<EOD
|
||||||
<html>
|
<html>
|
||||||
|
@ -14,17 +15,6 @@ class HomeTheme extends Themelet {
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
$hh
|
$hh
|
||||||
</head>
|
</head>
|
||||||
<style>
|
|
||||||
div#front-page h1 {font-size: 4em; margin-top: 2em; margin-bottom: 0px; text-align: center; border: none; background: none; box-shadow: none; -webkit-box-shadow: none; -moz-box-shadow: none;}
|
|
||||||
div#front-page {text-align:center;}
|
|
||||||
.space {margin-bottom: 1em;}
|
|
||||||
div#front-page div#links a {margin: 0 0.5em;}
|
|
||||||
div#front-page li {list-style-type: none; margin: 0;}
|
|
||||||
@media (max-width: 800px) {
|
|
||||||
div#front-page h1 {font-size: 3em; margin-top: 0.5em; margin-bottom: 0.5em;}
|
|
||||||
#counter {display: none;}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<body>
|
<body>
|
||||||
$body
|
$body
|
||||||
</body>
|
</body>
|
||||||
|
|
Reference in a new issue