Add languages, categorized them, add rechaptcha

This commit is contained in:
JoseluCross
2018-09-16 13:04:58 +02:00
parent 6d2466b5b1
commit d71a111fe9
14 changed files with 225 additions and 88 deletions

View File

@@ -76,13 +76,17 @@ p{
margin-bottom: 30px; margin-bottom: 30px;
} }
.codeFilterCheckBox, .codeFilterButton{ .codeFilterCheckBox, .codeFilterButton, .codeFilterTitle{
margin: 0.2em 0; margin: 0.2em 0;
padding: 0; padding: 0;
width: 100px; width: 100px;
float: left; float: left;
} }
.codeFilterTitle {
font-weight: bold;
}
.codeFilterSearch { .codeFilterSearch {
margin-top: 1em; margin-top: 1em;
} }
@@ -136,11 +140,16 @@ p{
transform: rotate(180deg); transform: rotate(180deg);
} }
#filterBlock{ .sub-depth{
border-radius: 5px;
box-shadow: inset 0px 0px 5px rgba(119, 119, 119, 0.205);
}
#filterBlock, .filterBlock{
align-content: center; align-content: center;
width: 90%; width: 90%;
margin-left: 7%; margin-left: 5%;
margin-right: 3%; margin-right: 5%;
} }
#user{ #user{
@@ -164,6 +173,16 @@ p{
animation: spin 2s linear infinite; animation: spin 2s linear infinite;
} }
@media (min-width: 992px) {
.nopadding {
padding: 0%;
}
}
.nomargin {
margin: 0%;
}
@keyframes spin { @keyframes spin {
0% { transform: rotate(0deg); } 0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); } 100% { transform: rotate(360deg); }

View File

@@ -19,7 +19,7 @@
<select id="lang" name="lang" required="required" class="form-control"> <select id="lang" name="lang" required="required" class="form-control">
<option value=""></option> <option value=""></option>
{% for key,value in supported %} {% for key,value in supported %}
<option value="{{ key }}">{{ value }}</option> <option value="{{ key }}">{{ value[0] }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
@@ -52,7 +52,9 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-12 col-sm-12"> <div class="col-sm-12 col-sm-12">
<button type="submit" class="btn btn-success btn-block">Submit</button> <button type="submit" class="btn btn-success g-recaptcha btn-block"
data-sitekey="6Lc7gXAUAAAAAJRaFo99vIkOUWckuGW8IOLtUxwZ"
data-callback="YourOnSubmitFn">Submit</button>
</div> </div>
</div> </div>
</form> </form>

View File

@@ -2,7 +2,6 @@
<html> <html>
<head> <head>
<title>{{ page.title }}</title> <title>{{ page.title }}</title>
<link type="text/css" rel="stylesheet" href="{{ path.css }}/bootstrap-paper.css"/> <link type="text/css" rel="stylesheet" href="{{ path.css }}/bootstrap-paper.css"/>
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="{{ path.css }}/main.css"/> <link type="text/css" rel="stylesheet" href="{{ path.css }}/main.css"/>
@@ -16,6 +15,7 @@
<script src="{{ path.js }}/highlight.pack.js"></script> <script src="{{ path.js }}/highlight.pack.js"></script>
<script src="{{ path.js }}/jquery-3.2.1.min.js"></script> <script src="{{ path.js }}/jquery-3.2.1.min.js"></script>
<script src="{{ path.js }}/bootstrap.min.js"></script> <script src="{{ path.js }}/bootstrap.min.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<script src="{{ path.js }}/functions.js"></script> <script src="{{ path.js }}/functions.js"></script>
</head> </head>
<body> <body>

View File

@@ -76,7 +76,7 @@
<option value=""></option> <option value=""></option>
{% for key,value in supported %} {% for key,value in supported %}
{% if key not in page.existedLangs %} {% if key not in page.existedLangs %}
<option value="{{ key }}"> {{ value }} </option> <option value="{{ key }}"> {{ value[0] }} </option>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</select> </select>

View File

@@ -1,16 +1,28 @@
<div style="text-align: center; margin-top:10px; "><button class="btn btn-default" onclick="mostrar('filterBlock')">Filters</button></div> <div style="text-align: center; margin-top:10px; "><button class="btn btn-default" onclick="mostrar('filterBlock')">Filters</button></div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="filterBlock" style="display: none;"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="filterBlock" style="display: none;">
<div class="container-fluid">
{% for key,value in page.supported %}
<div class='codeFilterCheckBox'><input type='checkbox' class='codeFilterCheckBoxInput' checked='true' value='{{ key }}' onclick="getAjax()"> {{ value }}</div>
{% endfor %}
<div class='codeFilterCheckBox'><button type='button' class='codeFilterCheckBoxInput btn btn-default btn-sm' onclick="unselectAll()">Unselect all</button></div>
<div class="container"></div>
<div class="row"> <div class="row">
<div class="codeFilterSearch col-md-11"> {% for key,value in page.grouped %}
<div class="col-lg-{{ value[1] }} col-md-{{ value[1] }} nopadding" style="{% if loop.first %}padding-left:15px {% elseif loop.last %}padding-right:15px{% endif %}">
<div class="row nomargin">
<div class='codeFilterCheckBox codeFilterTitle'>{{ key }}</div>
</div>
<div class="row nomargin">
{% for lang in value[0] %}
<div class='codeFilterCheckBox'><input type='checkbox' class='codeFilterCheckBoxInput' checked='true' value='{{ lang[0] }}' onclick="getAjax()"> {{ lang[1] }}</div>
{% endfor %}
</div>
</div>
{% endfor %}
</div>
<div class="row nomargin">
<div class='codeFilterCheckBox'><button type='button' class='codeFilterCheckBoxInput btn btn-default btn-sm' onclick="unselectAll()">Unselect all</button></div>
</div>
<div class="row">
<div class="codeFilterSearch col-md-12">
<input type="text" class="codeFilterSearchInput" id="search" name="search" placeholder="Code's name or description" onkeyup="getAjax()"> <input type="text" class="codeFilterSearchInput" id="search" name="search" placeholder="Code's name or description" onkeyup="getAjax()">
</div> </div>
{#<div class="codeFilterButton col-md-4"><button class="btn btn-default" onclick="getAjax()">Filter</button></div>#} {#<div class="codeFilterButton col-md-4"><button class="btn btn-default" onclick="getAjax()">Filter</button></div>#}
</div> </div>
</div>
</div> </div>

View File

@@ -80,7 +80,9 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-success">Submit</button> <button type="submit" class="btn btn-success g-recaptcha"
data-sitekey="6Lc7gXAUAAAAAJRaFo99vIkOUWckuGW8IOLtUxwZ"
data-callback="YourOnSubmitFn">Submit</button>
</div> </div>
</div> </div>
<div class="col-sm-offset-1 col-sm-12"> <div class="col-sm-offset-1 col-sm-12">

View File

@@ -26,7 +26,8 @@ function reHightlight(){
function mostrar(div) { function mostrar(div) {
obj = document.getElementById(div); obj = document.getElementById(div);
obj.style.display = (obj.style.display == 'none') ? 'block' : 'none'; $(obj).slideToggle();
//obj.style.display = (obj.style.display == 'none') ? 'block' : 'none';
} }
function getAjax() { function getAjax() {

103
Source/composer.lock generated
View File

@@ -1,23 +1,23 @@
{ {
"_readme": [ "_readme": [
"This file locks the dependencies of your project to a known state", "This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "c34d26c2711c26f871ff9ca8a4401104", "content-hash": "c34d26c2711c26f871ff9ca8a4401104",
"packages": [ "packages": [
{ {
"name": "jkanetwork/dbwrapper", "name": "jkanetwork/dbwrapper",
"version": "1.5.0", "version": "1.5.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://gitlab.com/CodeSolutionsProject/DBWrapper.git", "url": "https://gitlab.com/CodeSolutionsProject/DBWrapper.git",
"reference": "d366ae0f1f25d6a89c8c5a379118bf92aca45bdd" "reference": "1bc58622f2f520286f5de7058fc5b9a97921003b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://gitlab.com/api/v4/projects/CodeSolutionsProject%2FDBWrapper/repository/archive.zip?sha=d366ae0f1f25d6a89c8c5a379118bf92aca45bdd", "url": "https://gitlab.com/api/v4/projects/CodeSolutionsProject%2FDBWrapper/repository/archive.zip?sha=1bc58622f2f520286f5de7058fc5b9a97921003b",
"reference": "d366ae0f1f25d6a89c8c5a379118bf92aca45bdd", "reference": "1bc58622f2f520286f5de7058fc5b9a97921003b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -46,20 +46,78 @@
"sqlite", "sqlite",
"wrapper" "wrapper"
], ],
"time": "2018-05-16T13:37:18+00:00" "time": "2018-05-16T15:47:31+00:00"
}, },
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-ctype",
"version": "v1.8.0", "version": "v1.9.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git", "url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "3296adf6a6454a050679cde90f95350ad604b171" "reference": "e3d826245268269cd66f8326bd8bc066687b4a19"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3296adf6a6454a050679cde90f95350ad604b171", "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19",
"reference": "3296adf6a6454a050679cde90f95350ad604b171", "reference": "e3d826245268269cd66f8326bd8bc066687b4a19",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
},
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"time": "2018-08-06T14:22:27+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.9.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/d0cd638f4634c16d8df4508e847f14e9e43168b8",
"reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -71,7 +129,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.8-dev" "dev-master": "1.9-dev"
} }
}, },
"autoload": { "autoload": {
@@ -105,24 +163,25 @@
"portable", "portable",
"shim" "shim"
], ],
"time": "2018-04-26T10:06:28+00:00" "time": "2018-08-06T14:22:27+00:00"
}, },
{ {
"name": "twig/twig", "name": "twig/twig",
"version": "v2.4.8", "version": "v2.5.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/twigphp/Twig.git", "url": "https://github.com/twigphp/Twig.git",
"reference": "7b604c89da162034bdf4bb66310f358d313dd16d" "reference": "6a5f676b77a90823c2d4eaf76137b771adf31323"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/7b604c89da162034bdf4bb66310f358d313dd16d", "url": "https://api.github.com/repos/twigphp/Twig/zipball/6a5f676b77a90823c2d4eaf76137b771adf31323",
"reference": "7b604c89da162034bdf4bb66310f358d313dd16d", "reference": "6a5f676b77a90823c2d4eaf76137b771adf31323",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.0", "php": "^7.0",
"symfony/polyfill-ctype": "^1.8",
"symfony/polyfill-mbstring": "~1.0" "symfony/polyfill-mbstring": "~1.0"
}, },
"require-dev": { "require-dev": {
@@ -133,7 +192,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.4-dev" "dev-master": "2.5-dev"
} }
}, },
"autoload": { "autoload": {
@@ -162,16 +221,16 @@
}, },
{ {
"name": "Twig Team", "name": "Twig Team",
"homepage": "http://twig.sensiolabs.org/contributors", "homepage": "https://twig.symfony.com/contributors",
"role": "Contributors" "role": "Contributors"
} }
], ],
"description": "Twig, the flexible, fast, and secure template language for PHP", "description": "Twig, the flexible, fast, and secure template language for PHP",
"homepage": "http://twig.sensiolabs.org", "homepage": "https://twig.symfony.com",
"keywords": [ "keywords": [
"templating" "templating"
], ],
"time": "2018-04-02T09:24:19+00:00" "time": "2018-07-13T07:18:09+00:00"
} }
], ],
"packages-dev": [], "packages-dev": [],

View File

@@ -0,0 +1 @@
{"ada": ["Ada", "Programming"], "apache": ["Apache", "Config"], "arduino": ["Arduino", "Programming"], "bash": ["Bash", "Script"], "basic": ["Basic", "Programming"], "bat": ["Batch", "Script"], "clojure": ["Clojure", "Programming"], "cmake": ["CMake", "Config"], "cs": ["C#", "Programming"], "cpp": ["C/C++", "Programming"], "css": ["CSS", "Markup"], "coffescript": ["CoffeScript", "Programming"], "dart": ["Dart", "Programming"], "delphi": ["Delphi", "Programming"], "dockerfile": ["Docker", "Config"], "fortran": ["Fortran", "Programming"], "fsharp": ["F#", "Programming"], "go": ["Go", "Programming"], "groovy": ["Groovy", "Programming"], "haskell": ["Haskell", "Programming"], "xml": ["HTML/XML", "Markup"], "ini": ["Ini", "Config"], "json": ["JSON", "Data"], "java": ["Java", "Programming"], "javascript": ["JavaScript", "Programming"], "kotlin": ["Kotlin", "Programming"], "less": ["Less", "Markup"], "lua": ["Lua", "Programming"], "lisp": ["Lisp", "Programming"], "makefile": ["Makefile", "Config"], "markdown": ["Markdown", "Markup"], "matlab": ["Matlab", "Mathematics"], "maxima": ["Maxima", "Mathematics"], "nginx": ["Nginx", "Config"], "objectivec": ["Objective-C", "Programming"], "php": ["PHP", "Programming"], "perl": ["Perl", "Programming"], "powershell": ["PowerShell", "Script"], "prolog": ["Prolog", "Programming"], "python": ["Python", "Programming"], "r": ["R", "Mathematics"], "ruby": ["Ruby", "Programming"], "rust": ["Rust", "Programming"], "scss": ["Sass", "Markup"], "scala": ["Scala", "Programming"], "smalltalk": ["Samlltalk", "Programming"], "sql": ["SQL", "Data"], "swift": ["Swift", "Programming"], "twig": ["Twig", "Markup"], "typescript": ["TypeScript", "Programming"], "vbnet": ["VB.Net", "Programming"], "yaml": ["YAML", "Data"]}

View File

@@ -1,39 +1,52 @@
ada:Ada ada:Ada:Programming
arduino:Arduino apache:Apache:Config
bash:Bash arduino:Arduino:Programming
basic:Basic bash:Bash:Script
cs:C# basic:Basic:Programming
cpp:C/C++ bat:Batch:Script
css:CSS clojure:Clojure:Programming
coffescript:CoffeScript cmake:CMake:Config
dart:Dart cs:C#:Programming
delphi:Delphi cpp:C/C++:Programming
fortran:Fortran css:CSS:Markup
go:Go coffescript:CoffeScript:Programming
groovy:Groovy dart:Dart:Programming
haskell:Haskell delphi:Delphi:Programming
xml:HTML/XML dockerfile:Docker:Config
json:JSON fortran:Fortran:Programming
java:Java fsharp:F#:Programming
javascript:JavaScript go:Go:Programming
kotlin:Kotlin groovy:Groovy:Programming
less:Less haskell:Haskell:Programming
lua:Lua xml:HTML/XML:Markup
markdown:Markdown Ini:ini:Config
objectivec:Objective-C json:JSON:Data interchange
php:PHP java:Java:Programming
perl:Perl javascript:JavaScript:Programming
powershell:PowerShell kotlin:Kotlin:Programming
python:Python less:Less:Markup
r:R lua:Lua:Programming
ruby:Ruby lisp:Lisp:Programming
rust:Rust makefile:Makefile:Config
scss:Sass markdown:Markdown:Markup
scala:Scala matlab:Matlab:Mathematics
smalltalk:Samlltalk maxima:Maxima:Mathematics
sql:SQL nginx:Nginx:Config
swift:Swift objectivec:Objective-C:Programming
twig:Twig php:PHP:Programming
typescript:TypeScript perl:Perl:Programming
vbnet:VB.Net powershell:PowerShell:Script
yaml:YAML prolog:Prolog:Programming
python:Python:Programming
r:R:Mathematics
ruby:Ruby:Programming
rust:Rust:Programming
scss:Sass:Markup
scala:Scala:Programming
smalltalk:Samlltalk:Programming
sql:SQL:Data
swift:Swift:Programming
twig:Twig:Markup
typescript:TypeScript:Programming
vbnet:VB.Net:Programming
yaml:YAML:Data

View File

@@ -211,15 +211,13 @@ class DB
} }
} }
} }
if(count($array)==1)
$where = $where . "S.Lang<>''";
if (isset($array["o"])) if (isset($array["o"]))
$first = $array["o"] * 10; $first = $array["o"] * 10;
else else
$first = 0; $first = 0;
if(array_key_exists("search",$array)) if(array_key_exists("search",$array))
$search = $array("search"); $search = $this->search($array["search"]);
else else
$search = ""; $search = "";
$queryLast = ") AND Version = (SELECT MAX(Version) FROM Sources WHERE S.Lang = Lang AND S.IDC = IDC)" . $search . " ORDER BY Modification DESC LIMIT $first, 10"; $queryLast = ") AND Version = (SELECT MAX(Version) FROM Sources WHERE S.Lang = Lang AND S.IDC = IDC)" . $search . " ORDER BY Modification DESC LIMIT $first, 10";

View File

@@ -18,7 +18,8 @@ $path = array(
"js" => "assets/js/", "js" => "assets/js/",
"img" => "assets/img/", "img" => "assets/img/",
); );
$supported = ksonParse('data/supported.kson'); $string = file_get_contents(__DIR__."/../data/supported.json");
$supported = json_decode($string, true);
$loader = new Twig_Loader_Filesystem($path['html']); $loader = new Twig_Loader_Filesystem($path['html']);
$twig = new Twig_Environment($loader); $twig = new Twig_Environment($loader);
$user = array(); $user = array();
@@ -143,7 +144,8 @@ function firstPage($filter=false,$globalSearch=false){
"description" => "Sharing your solution with all", "description" => "Sharing your solution with all",
"last" => $last, "last" => $last,
"supported" => $supported, "supported" => $supported,
"page" => "home" "page" => "home",
"grouped" => groupByCategory($supported)
); );
if(!$filter) if(!$filter)
echo $twig->render("firstpage.twig",array("page" => $page, "path" => $path, "user" => $user)); echo $twig->render("firstpage.twig",array("page" => $page, "path" => $path, "user" => $user));
@@ -237,7 +239,7 @@ function codeViewer(){
if($array){ if($array){
$page = array( $page = array(
"title" => "$array[Name] by $array[nick]", "title" => "$array[Name] by $array[nick]",
"description" => "$array[Name] by $array[nick] in ".$supported[$_GET['lang']], "description" => "$array[Name] by $array[nick] in ".$supported[$_GET['lang']][0],
"otherV" => false, "otherV" => false,
"otherI" => false, "otherI" => false,
"existedLangs" => $db->loadLangs($_GET['id']), "existedLangs" => $db->loadLangs($_GET['id']),

View File

@@ -20,7 +20,7 @@ function lastToArray($db,&$query,&$supported){
"version" => $var["Version"], "version" => $var["Version"],
"name" => $var["Name"], "name" => $var["Name"],
"nick" => $var["nick"], "nick" => $var["nick"],
"lLang" => $supported[$var["Lang"]], "lLang" => $supported[$var["Lang"]][0],
"description" => $var["Description"], "description" => $var["Description"],
"code" => html_entity_decode($var["Code"]), "code" => html_entity_decode($var["Code"]),
); );
@@ -37,7 +37,7 @@ function allCodeToArray(&$query,&$supported){
"name" => $query['Name'], "name" => $query['Name'],
"nick" => $query['nick'], "nick" => $query['nick'],
"idu" => $query['IDU'], "idu" => $query['IDU'],
"lLang" => $supported[$query['Lang']], "lLang" => $supported[$query['Lang']][0],
"description" => $query['Description'], "description" => $query['Description'],
"code" => html_entity_decode($query['Code']), "code" => html_entity_decode($query['Code']),
"input" => html_entity_decode($query['Input']), "input" => html_entity_decode($query['Input']),
@@ -56,7 +56,7 @@ function otherImplementationToArray($db,&$query,&$supported){
$array = array $array = array
( "lang" => $var["Lang"], ( "lang" => $var["Lang"],
"version" => $var["Version"], "version" => $var["Version"],
"lLang" => $supported[$var["Lang"]], "lLang" => $supported[$var["Lang"]][0],
"code" => html_entity_decode($var["Code"]), "code" => html_entity_decode($var["Code"]),
); );
array_push($other,$array); array_push($other,$array);

View File

@@ -50,3 +50,31 @@ function ksonParse($path){
die('<h3>Error, kson file not exist</h3>'); die('<h3>Error, kson file not exist</h3>');
} }
} }
/**
* Group by $supported
*/
function groupByCategory(&$supported){
$grouped = Array();
foreach($supported as $key => $val){
if(!array_key_exists($val[1],$grouped)){
switch($val[1]){
case "Programming":
$num=5;
break;
case "Config":
case "Markup":
$num=2;
break;
case "Script":
case "Data":
case "Mathematics":
$num=1;
break;
}
$grouped[$val[1]] = Array(Array(),$num);
}
array_push($grouped[$val[1]][0],[$key,$val[0]]);
}
return $grouped;
}