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;
}
.codeFilterCheckBox, .codeFilterButton{
.codeFilterCheckBox, .codeFilterButton, .codeFilterTitle{
margin: 0.2em 0;
padding: 0;
width: 100px;
float: left;
}
.codeFilterTitle {
font-weight: bold;
}
.codeFilterSearch {
margin-top: 1em;
}
@@ -136,11 +140,16 @@ p{
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;
width: 90%;
margin-left: 7%;
margin-right: 3%;
margin-left: 5%;
margin-right: 5%;
}
#user{
@@ -164,6 +173,16 @@ p{
animation: spin 2s linear infinite;
}
@media (min-width: 992px) {
.nopadding {
padding: 0%;
}
}
.nomargin {
margin: 0%;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }

View File

@@ -19,7 +19,7 @@
<select id="lang" name="lang" required="required" class="form-control">
<option value=""></option>
{% for key,value in supported %}
<option value="{{ key }}">{{ value }}</option>
<option value="{{ key }}">{{ value[0] }}</option>
{% endfor %}
</select>
</div>
@@ -52,7 +52,9 @@
</div>
<div class="form-group">
<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>
</form>

View File

@@ -2,7 +2,6 @@
<html>
<head>
<title>{{ page.title }}</title>
<link type="text/css" rel="stylesheet" href="{{ path.css }}/bootstrap-paper.css"/>
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<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 }}/jquery-3.2.1.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>
</head>
<body>

View File

@@ -76,7 +76,7 @@
<option value=""></option>
{% for key,value in supported %}
{% if key not in page.existedLangs %}
<option value="{{ key }}"> {{ value }} </option>
<option value="{{ key }}"> {{ value[0] }} </option>
{% endif %}
{% endfor %}
</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 class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="filterBlock" style="display: none;">
{% 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="container-fluid">
<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()">
</div>
{#<div class="codeFilterButton col-md-4"><button class="btn btn-default" onclick="getAjax()">Filter</button></div>#}
</div>
</div>
</div>

View File

@@ -80,7 +80,9 @@
</div>
<div class="form-group">
<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 class="col-sm-offset-1 col-sm-12">

View File

@@ -26,7 +26,8 @@ function reHightlight(){
function mostrar(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() {

103
Source/composer.lock generated
View File

@@ -1,23 +1,23 @@
{
"_readme": [
"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"
],
"content-hash": "c34d26c2711c26f871ff9ca8a4401104",
"packages": [
{
"name": "jkanetwork/dbwrapper",
"version": "1.5.0",
"version": "1.5.1",
"source": {
"type": "git",
"url": "https://gitlab.com/CodeSolutionsProject/DBWrapper.git",
"reference": "d366ae0f1f25d6a89c8c5a379118bf92aca45bdd"
"reference": "1bc58622f2f520286f5de7058fc5b9a97921003b"
},
"dist": {
"type": "zip",
"url": "https://gitlab.com/api/v4/projects/CodeSolutionsProject%2FDBWrapper/repository/archive.zip?sha=d366ae0f1f25d6a89c8c5a379118bf92aca45bdd",
"reference": "d366ae0f1f25d6a89c8c5a379118bf92aca45bdd",
"url": "https://gitlab.com/api/v4/projects/CodeSolutionsProject%2FDBWrapper/repository/archive.zip?sha=1bc58622f2f520286f5de7058fc5b9a97921003b",
"reference": "1bc58622f2f520286f5de7058fc5b9a97921003b",
"shasum": ""
},
"require": {
@@ -46,20 +46,78 @@
"sqlite",
"wrapper"
],
"time": "2018-05-16T13:37:18+00:00"
"time": "2018-05-16T15:47:31+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.8.0",
"name": "symfony/polyfill-ctype",
"version": "v1.9.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "3296adf6a6454a050679cde90f95350ad604b171"
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "e3d826245268269cd66f8326bd8bc066687b4a19"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3296adf6a6454a050679cde90f95350ad604b171",
"reference": "3296adf6a6454a050679cde90f95350ad604b171",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19",
"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": ""
},
"require": {
@@ -71,7 +129,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.8-dev"
"dev-master": "1.9-dev"
}
},
"autoload": {
@@ -105,24 +163,25 @@
"portable",
"shim"
],
"time": "2018-04-26T10:06:28+00:00"
"time": "2018-08-06T14:22:27+00:00"
},
{
"name": "twig/twig",
"version": "v2.4.8",
"version": "v2.5.0",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "7b604c89da162034bdf4bb66310f358d313dd16d"
"reference": "6a5f676b77a90823c2d4eaf76137b771adf31323"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/7b604c89da162034bdf4bb66310f358d313dd16d",
"reference": "7b604c89da162034bdf4bb66310f358d313dd16d",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/6a5f676b77a90823c2d4eaf76137b771adf31323",
"reference": "6a5f676b77a90823c2d4eaf76137b771adf31323",
"shasum": ""
},
"require": {
"php": "^7.0",
"symfony/polyfill-ctype": "^1.8",
"symfony/polyfill-mbstring": "~1.0"
},
"require-dev": {
@@ -133,7 +192,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
"dev-master": "2.5-dev"
}
},
"autoload": {
@@ -162,16 +221,16 @@
},
{
"name": "Twig Team",
"homepage": "http://twig.sensiolabs.org/contributors",
"homepage": "https://twig.symfony.com/contributors",
"role": "Contributors"
}
],
"description": "Twig, the flexible, fast, and secure template language for PHP",
"homepage": "http://twig.sensiolabs.org",
"homepage": "https://twig.symfony.com",
"keywords": [
"templating"
],
"time": "2018-04-02T09:24:19+00:00"
"time": "2018-07-13T07:18:09+00:00"
}
],
"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
arduino:Arduino
bash:Bash
basic:Basic
cs:C#
cpp:C/C++
css:CSS
coffescript:CoffeScript
dart:Dart
delphi:Delphi
fortran:Fortran
go:Go
groovy:Groovy
haskell:Haskell
xml:HTML/XML
json:JSON
java:Java
javascript:JavaScript
kotlin:Kotlin
less:Less
lua:Lua
markdown:Markdown
objectivec:Objective-C
php:PHP
perl:Perl
powershell:PowerShell
python:Python
r:R
ruby:Ruby
rust:Rust
scss:Sass
scala:Scala
smalltalk:Samlltalk
sql:SQL
swift:Swift
twig:Twig
typescript:TypeScript
vbnet:VB.Net
yaml:YAML
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 interchange
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

@@ -211,15 +211,13 @@ class DB
}
}
}
if(count($array)==1)
$where = $where . "S.Lang<>''";
if (isset($array["o"]))
$first = $array["o"] * 10;
else
$first = 0;
if(array_key_exists("search",$array))
$search = $array("search");
$search = $this->search($array["search"]);
else
$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";

View File

@@ -18,7 +18,8 @@ $path = array(
"js" => "assets/js/",
"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']);
$twig = new Twig_Environment($loader);
$user = array();
@@ -143,7 +144,8 @@ function firstPage($filter=false,$globalSearch=false){
"description" => "Sharing your solution with all",
"last" => $last,
"supported" => $supported,
"page" => "home"
"page" => "home",
"grouped" => groupByCategory($supported)
);
if(!$filter)
echo $twig->render("firstpage.twig",array("page" => $page, "path" => $path, "user" => $user));
@@ -237,7 +239,7 @@ function codeViewer(){
if($array){
$page = array(
"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,
"otherI" => false,
"existedLangs" => $db->loadLangs($_GET['id']),

View File

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

View File

@@ -50,3 +50,31 @@ function ksonParse($path){
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;
}