ADD: Добавлена страница поиска
* Изменена детальная страница статистики * Мелкие изменения css
This commit is contained in:
parent
8a7d2147bd
commit
18a610ac83
|
@ -3,22 +3,65 @@
|
|||
namespace App\Controllers;
|
||||
use Hleb\Constructor\Handlers\Request;
|
||||
use App\Models\NotificationsModel;
|
||||
use App\Models\SearchModel;
|
||||
use Parsedown;
|
||||
use Base;
|
||||
|
||||
class SearchController extends \MainController
|
||||
{
|
||||
// Поиск
|
||||
// Форма поиска
|
||||
public function index()
|
||||
{
|
||||
|
||||
|
||||
$uid = Base::getUid();
|
||||
$data = [
|
||||
'title' => 'Поиск по сайту',
|
||||
'description' => 'Страница поиска по сайту',
|
||||
'title' => lang('Search') . ' | ' . $GLOBALS['conf']['sitename'],
|
||||
'description' => 'Страница поиска по сайту ' . $GLOBALS['conf']['sitename'],
|
||||
'h1' => lang('Search'),
|
||||
];
|
||||
|
||||
return view("search/index", ['data' => $data, 'uid' => $uid]);
|
||||
}
|
||||
|
||||
// Заглушка для поиска
|
||||
public function qSearch()
|
||||
{
|
||||
$query = \Request::getPost('q');
|
||||
|
||||
if (!empty($query))
|
||||
{
|
||||
if (Base::getStrlen($query) < 3) {
|
||||
Base::addMsg('Слишком короткий поисковый запрос', 'error');
|
||||
redirect('/search');
|
||||
} else if (Base::getStrlen($query) > 128) {
|
||||
Base::addMsg('Слишком длинный поисковый запрос', 'error');
|
||||
redirect('/search');
|
||||
} else {
|
||||
$qa = SearchModel::getSearch($query);
|
||||
}
|
||||
|
||||
} else {
|
||||
Base::addMsg('Задан пустой поисковый запрос.', 'error');
|
||||
redirect('/search');
|
||||
}
|
||||
|
||||
$Parsedown = new Parsedown();
|
||||
$Parsedown->setSafeMode(true); // безопасность
|
||||
|
||||
$result = Array();
|
||||
foreach($qa as $ind => $row){
|
||||
$row['post_title'] = $row['post_title'];
|
||||
$row['post_content'] = $Parsedown->line(mb_substr($row['post_content'],0,120, 'utf-8').'...');
|
||||
$row['post_slug'] = $row['post_slug'];
|
||||
$result[$ind] = $row;
|
||||
}
|
||||
|
||||
$uid = Base::getUid();
|
||||
$data = [
|
||||
'title' => lang('Search') . ' | ' . $GLOBALS['conf']['sitename'],
|
||||
'description' => 'Страница поиска по сайту ' . $GLOBALS['conf']['sitename'],
|
||||
'h1' => lang('Search'),
|
||||
];
|
||||
|
||||
return view("search/index", ['data' => $data, 'uid' => $uid, 'result' => $result, 'query' => $query]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,4 +18,5 @@ return [
|
|||
'Privacy' => 'Конфедициальность',
|
||||
'About' => 'О нас',
|
||||
'Info' => 'Информация',
|
||||
'Search' => 'Поиск',
|
||||
];
|
||||
|
|
19
app/Models/SearchModel.php
Normal file
19
app/Models/SearchModel.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
use DB;
|
||||
use PDO;
|
||||
|
||||
class SearchModel extends \MainModel
|
||||
{
|
||||
public static function getSearch($query)
|
||||
{
|
||||
$sql = "SELECT post_id, post_slug, post_title, post_content FROM posts
|
||||
WHERE post_content LIKE :qa1 OR post_title LIKE :qa2 ORDER BY post_id LIMIT 10";
|
||||
$result_q = DB::run($sql,['qa1' => "%".$query."%", 'qa2' => "%".$query."%"]);
|
||||
$result = $result_q->fetchall(PDO::FETCH_ASSOC);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
|
@ -26,7 +26,7 @@ class MainConnector implements Connector
|
|||
"Base" => "app/Libraries/Base.php",
|
||||
"DB" => "database/DB.php",
|
||||
"XdORM\XD" => "vendor/phphleb/xdorm/XD.php",
|
||||
"Phphleb\Debugpan\DPanel" => "vendor/phphleb/debugpan/DPanel.php",
|
||||
//"Phphleb\Debugpan\DPanel" => "vendor/phphleb/debugpan/DPanel.php",
|
||||
|
||||
// https://github.com/JacksonJeans/php-mail
|
||||
"JacksonJeans\MailException" => "app/Libraries/php-mail/src/JacksonJeans/MailException.class.php",
|
||||
|
|
|
@ -1,4 +1,17 @@
|
|||
|
||||
.stats {
|
||||
grid-column-start: 1;
|
||||
grid-column-end: 4;
|
||||
padding: 0.4rem 0.5rem;
|
||||
}
|
||||
#canvas {
|
||||
display: block;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: -1;
|
||||
}
|
||||
.canvas-telo {
|
||||
height: 125px;
|
||||
}
|
||||
.time-cont {
|
||||
width: 100%;
|
||||
max-width: 830px;
|
||||
|
@ -102,9 +115,8 @@
|
|||
.img-email{width:119px;vertical-align: top;}
|
||||
.tag {margin-left: 24px; display: inline-block;}
|
||||
.bl-left .title {font-size:21px;}
|
||||
h1.user {margin: 0;color:#f56400;font-size: 4em;font-family: Georgia,Arial,sans-serif;}
|
||||
h1.prof {margin: 0;color:#f56400;font-size: 3em;font-family: Georgia,Arial,sans-serif;}
|
||||
h3.user {margin: 0;color: #666;font-weight: 300;font-size: 1.3em;}
|
||||
h1 {margin: 0;color:#f56400;font-size: 3em;font-family: Georgia,Arial,sans-serif;}
|
||||
h3 {margin: 0;color: #666;font-weight: 300;font-size: 1.3em;}
|
||||
hr.user {display: block;height: 1px;margin: 1em 0;width: 200px;border: 0;border-top-width: 0px;border-top-style:none;
|
||||
border-top-color: currentcolor;border-top: 2px solid #999;padding: 0;}
|
||||
.user-img{background: url(/static/img/dev.jpg);height: 119px;width:70%;}
|
||||
|
@ -127,12 +139,12 @@ h3.suggested-topics-message a:hover {color: #f56400;}
|
|||
.img-top-user {vertical-align: middle;width:32px;margin-right: 5px;border-radius: 3px;}
|
||||
.img-blog {margin-top: 12px;}
|
||||
|
||||
@media (max-width: 850px){
|
||||
@media (max-width: 720px){
|
||||
.prof-txt{white-space: nowrap; overflow: hidden; padding: 5px; text-overflow: ellipsis;}
|
||||
.prof-blog-2 {float: left;width: 33%;}
|
||||
.prof-num, h1.prof {font-size: 2em;}
|
||||
.prof-txt, h3.user {font-size: 1em;}
|
||||
.prof-num-u {font-size: 1.2em;}
|
||||
.prof-num img.avatar {width: 34px;height:34px;}
|
||||
.no-mob {display: none;}
|
||||
.no-mob, #canvas, .canvas-telo {display: none;}
|
||||
}
|
||||
|
|
|
@ -558,6 +558,9 @@ a.showpost span {
|
|||
.date.ots {
|
||||
margin: 0 0 0 12px;
|
||||
}
|
||||
.v-ots {
|
||||
margin: 15px 0;
|
||||
}
|
||||
.footer a, .footer {
|
||||
font-size: 13px;
|
||||
color: var(--color-gray-1);
|
||||
|
@ -939,6 +942,8 @@ textarea.mess {
|
|||
font-size: 14px;
|
||||
color: green;
|
||||
margin-bottom: 12px;
|
||||
grid-area: header;
|
||||
margin: 50px 16px 5px 10px;
|
||||
}
|
||||
|
||||
/* Диалог и детали */
|
||||
|
|
113
public/assets/js/canvas.js
Normal file
113
public/assets/js/canvas.js
Normal file
|
@ -0,0 +1,113 @@
|
|||
$(function() {
|
||||
let resizeReset = function() {
|
||||
w = canvasBody.width = 650; //window.innerWidth
|
||||
h = canvasBody.height = 120;
|
||||
}
|
||||
|
||||
const opts = {
|
||||
particleColor: "rgb(200,200,200)",
|
||||
lineColor: "rgb(200,200,200)",
|
||||
particleAmount: 10,
|
||||
defaultSpeed: 1,
|
||||
variantSpeed: 1,
|
||||
defaultRadius: 2,
|
||||
variantRadius: 2,
|
||||
linkRadius: 200,
|
||||
};
|
||||
|
||||
window.addEventListener("resize", function(){
|
||||
deBouncer();
|
||||
});
|
||||
|
||||
let deBouncer = function() {
|
||||
clearTimeout(tid);
|
||||
tid = setTimeout(function() {
|
||||
resizeReset();
|
||||
}, delay);
|
||||
};
|
||||
|
||||
let checkDistance = function(x1, y1, x2, y2){
|
||||
return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
|
||||
};
|
||||
|
||||
let linkPoints = function(point1, hubs){
|
||||
for (let i = 0; i < hubs.length; i++) {
|
||||
let distance = checkDistance(point1.x, point1.y, hubs[i].x, hubs[i].y);
|
||||
let opacity = 1 - distance / opts.linkRadius;
|
||||
if (opacity > 0) {
|
||||
drawArea.lineWidth = 0.5;
|
||||
drawArea.strokeStyle = `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${opacity})`;
|
||||
drawArea.beginPath();
|
||||
drawArea.moveTo(point1.x, point1.y);
|
||||
drawArea.lineTo(hubs[i].x, hubs[i].y);
|
||||
drawArea.closePath();
|
||||
drawArea.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Particle = function(xPos, yPos){
|
||||
this.x = Math.random() * w;
|
||||
this.y = Math.random() * h;
|
||||
this.speed = opts.defaultSpeed + Math.random() * opts.variantSpeed;
|
||||
this.directionAngle = Math.floor(Math.random() * 360);
|
||||
this.color = opts.particleColor;
|
||||
this.radius = opts.defaultRadius + Math.random() * opts. variantRadius;
|
||||
this.vector = {
|
||||
x: Math.cos(this.directionAngle) * this.speed,
|
||||
y: Math.sin(this.directionAngle) * this.speed
|
||||
};
|
||||
this.update = function(){
|
||||
this.border();
|
||||
this.x += this.vector.x;
|
||||
this.y += this.vector.y;
|
||||
};
|
||||
this.border = function(){
|
||||
if (this.x >= w || this.x <= 0) {
|
||||
this.vector.x *= -1;
|
||||
}
|
||||
if (this.y >= h || this.y <= 0) {
|
||||
this.vector.y *= -1;
|
||||
}
|
||||
if (this.x > w) this.x = w;
|
||||
if (this.y > h) this.y = h;
|
||||
if (this.x < 0) this.x = 0;
|
||||
if (this.y < 0) this.y = 0;
|
||||
};
|
||||
this.draw = function(){
|
||||
drawArea.beginPath();
|
||||
drawArea.arc(this.x, this.y, this.radius, 0, Math.PI*2);
|
||||
drawArea.closePath();
|
||||
drawArea.fillStyle = this.color;
|
||||
drawArea.fill();
|
||||
};
|
||||
};
|
||||
|
||||
function setup(){
|
||||
particles = [];
|
||||
resizeReset();
|
||||
for (let i = 0; i < opts.particleAmount; i++){
|
||||
particles.push( new Particle() );
|
||||
}
|
||||
window.requestAnimationFrame(loop);
|
||||
}
|
||||
|
||||
function loop(){
|
||||
window.requestAnimationFrame(loop);
|
||||
drawArea.clearRect(0,0,w,h);
|
||||
for (let i = 0; i < particles.length; i++){
|
||||
particles[i].update();
|
||||
particles[i].draw();
|
||||
}
|
||||
for (let i = 0; i < particles.length; i++){
|
||||
linkPoints(particles[i], particles);
|
||||
}
|
||||
}
|
||||
|
||||
const canvasBody = document.getElementById("canvas"),
|
||||
drawArea = canvasBody.getContext("2d");
|
||||
let delay = 200, tid,
|
||||
rgb = opts.lineColor.match(/\d+/g);
|
||||
resizeReset();
|
||||
setup();
|
||||
});
|
|
@ -16,7 +16,6 @@ $(function(){
|
|||
$('.cm_addentry').remove();
|
||||
$('.cm_add_link').show();
|
||||
});
|
||||
|
||||
// Show post body
|
||||
$(document).on("click", ".showpost", function(){
|
||||
var post_id = $(this).data('post_id');
|
||||
|
@ -31,7 +30,6 @@ $(function(){
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
// toggle dark mode
|
||||
$(document).on('click', '#toggledark', function() {
|
||||
var mode = getCookie("dayNight");
|
||||
|
@ -70,4 +68,4 @@ function getCookie(cname) {
|
|||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
};
|
|
@ -1,6 +1,6 @@
|
|||
<footer>
|
||||
<div class="right">
|
||||
<a title="<?= lang('Privacy'); ?>" href="/info/privacy"><?= lang('Privacy'); ?></a>
|
||||
<a title="<?= lang('Search'); ?>" href="/search"><?= lang('Search'); ?></a>
|
||||
<a title="<?= lang('Help'); ?>" href="/info"><?= lang('Help'); ?></a>
|
||||
<a title="<?= lang('About us'); ?>" href="/info/about"><?= lang('About'); ?></a>
|
||||
</div>
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
<?php $uri = Request::getUri(); ?>
|
||||
<aside id="sidebar">
|
||||
<a class="info-n<?php if($uri == '/info') { ?> active<?php } ?>" href="/info">• <?= lang('Info'); ?></a>
|
||||
<a class="info-n<?php if($uri == '/info/stats') { ?> active<?php } ?>" href="/info/stats">• <?= lang('Statistics'); ?></a>
|
||||
<a class="info-n<?php if($uri == '/info/privacy') { ?> active<?php } ?>" href="/info/privacy">• <?= lang('Privacy'); ?></a>
|
||||
<a class="info-n<?php if($uri == '/info/markdown') { ?> active<?php } ?>" href="/info/markdown">• <?= lang('Мarkdown'); ?></a>
|
||||
<a class="info-n<?php if($uri == '/info/about') { ?> active<?php } ?>" href="/info/about">• <?= lang('About'); ?></a>
|
||||
<div class="v-ots"></div>
|
||||
<a class="info-n<?php if($uri == '/info/stats') { ?> active<?php } ?>" href="/info/stats">• <?= lang('Statistics'); ?></a>
|
||||
</aside>
|
||||
|
|
|
@ -1,67 +1,68 @@
|
|||
<?php include TEMPLATE_DIR . '/header.php'; ?>
|
||||
<link rel="stylesheet" href="/assets/css/info.css">
|
||||
<main class="info">
|
||||
<div class="left-ots">
|
||||
<ul class="breadcrumb">
|
||||
<li class="breadcrumb-item">
|
||||
<a title="<?= lang('Home'); ?>" href="/"><?= lang('Home'); ?></a>
|
||||
</li>
|
||||
<li class="breadcrumb-item">
|
||||
<a title="<?= lang('Info'); ?>" href="/info"><?= lang('Info'); ?></a>
|
||||
</li>
|
||||
</ul>
|
||||
<script src="/assets/js/canvas.js"></script>
|
||||
<div class="stats">
|
||||
<ul class="breadcrumb">
|
||||
<li class="breadcrumb-item">
|
||||
<a title="<?= lang('Home'); ?>" href="/"><?= lang('Home'); ?></a>
|
||||
</li>
|
||||
<li class="breadcrumb-item">
|
||||
<a title="<?= lang('Info'); ?>" href="/info"><?= lang('Info'); ?></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<center>
|
||||
<h1>Статистика</h1>
|
||||
|
||||
<center>
|
||||
<div class="time-cont">
|
||||
<div class="prof-blog">
|
||||
<div class="prof-num-u"><?= $data['comm_num']; ?></div>
|
||||
<div class="prof-txt">комментариев</div>
|
||||
</div>
|
||||
<div class="prof-blog">
|
||||
<div class="prof-num-u"><span class="number"> <?= $data['user_num']; ?></span></div>
|
||||
<div class="prof-txt">участников</div>
|
||||
</div>
|
||||
<div class="prof-blog">
|
||||
<div class="prof-num-u"><?= $data['post_num']; ?></div>
|
||||
<div class="prof-txt">постов</div>
|
||||
</div>
|
||||
<div class="canvas-telo">
|
||||
<canvas id="canvas"> </canvas>
|
||||
</div>
|
||||
<div class="time-cont">
|
||||
<div class="prof-blog">
|
||||
<div class="prof-num-u"><?= $data['comm_num']; ?></div>
|
||||
<div class="prof-txt">комментариев</div>
|
||||
</div>
|
||||
<div class="prof-blog">
|
||||
<div class="prof-num-u"><span class="number"> <?= $data['user_num']; ?></span></div>
|
||||
<div class="prof-txt">участников</div>
|
||||
</div>
|
||||
<div class="prof-blog">
|
||||
<div class="prof-num-u"><?= $data['post_num']; ?></div>
|
||||
<div class="prof-txt">постов</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bord-3 new-str"></div>
|
||||
</center>
|
||||
<div class="bord-3 new-str"></div>
|
||||
</center>
|
||||
|
||||
<section class="time-cont">
|
||||
<ol class="time">
|
||||
<li class="-period">
|
||||
<span class="-time">'21</span>
|
||||
<ol class="-vrs">
|
||||
<li class="-vr"> Разработка сообщества... </li>
|
||||
</ol>
|
||||
</li>
|
||||
<li class="-period">
|
||||
<span class="-time">'21</span>
|
||||
<ol class="-vrs">
|
||||
<li class="-vr"> Начало работы. Изучаем HLEB. </li>
|
||||
</ol>
|
||||
</li>
|
||||
<li class="-period">
|
||||
<span class="-time">'20</span>
|
||||
<ol class="-vrs">
|
||||
<li class="-vr">
|
||||
Тестовая запись...
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
<section class="time-cont">
|
||||
<ol class="time">
|
||||
<li class="-period">
|
||||
<span class="-time">'21</span>
|
||||
<ol class="-vrs">
|
||||
<li class="-vr"> Разработка сообщества... </li>
|
||||
</ol>
|
||||
</li>
|
||||
<li class="-period">
|
||||
<span class="-time">'21</span>
|
||||
<ol class="-vrs">
|
||||
<li class="-vr"> Начало работы. Изучаем HLEB. </li>
|
||||
</ol>
|
||||
</li>
|
||||
<li class="-period">
|
||||
<span class="-time">'20</span>
|
||||
<ol class="-vrs">
|
||||
<li class="-vr">
|
||||
Тестовая запись...
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<p>Голосов: <br>
|
||||
- комментарии <b><?= $data['vote_comm_num']; ?></b> <br>
|
||||
- посты <b><?= $data['vote_post_num']; ?></b></p>
|
||||
<p>Голосов: <br>
|
||||
- комментарии <b><?= $data['vote_comm_num']; ?></b> <br>
|
||||
- посты <b><?= $data['vote_post_num']; ?></b></p>
|
||||
|
||||
<p><i>В стадии разработки...</i></p>
|
||||
</div>
|
||||
</main>
|
||||
<?php include 'menu.php'; ?>
|
||||
<p><i>В стадии разработки...</i></p>
|
||||
</div>
|
||||
<?php include TEMPLATE_DIR . '/footer.php'; ?>
|
|
@ -1,10 +1,32 @@
|
|||
<?php include TEMPLATE_DIR . '/header.php'; ?>
|
||||
<main>
|
||||
<div class="left-ots">
|
||||
<h1>Поиск</h1>
|
||||
<h1><?= $data['h1']; ?></h1>
|
||||
|
||||
<p>В стадии разработки</p>
|
||||
<form method="post" action="/search/q">
|
||||
<?= csrf_field() ?>
|
||||
<input type="text" name="q" id="search" class='search'/>
|
||||
|
||||
<input type="submit" value="Поиск" class="search" /><br />
|
||||
|
||||
</form>
|
||||
<?php if (!empty($result)) { ?>
|
||||
<div>Вы искали: <b><?= $query; ?></b></div>
|
||||
<?php } ?>
|
||||
|
||||
<br>
|
||||
|
||||
<?php if (!empty($result)) { ?>
|
||||
<?php foreach ($result as $post) { ?>
|
||||
<div class="search">
|
||||
<a href="/posts/<?= $post['post_slug'] ?>"><?= $post['post_title']; ?></a> <br>
|
||||
<?= $post['post_content']; ?>
|
||||
</div>
|
||||
<div class="v-ots"></div>
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<p>Поиск не дал результатов...<p>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</main>
|
||||
<?php include TEMPLATE_DIR . '/footer.php'; ?>
|
|
@ -113,6 +113,7 @@ Route::type('post')->get('/comments/addform')->controller('CommentController@add
|
|||
|
||||
// Поиск
|
||||
Route::get('/search')->controller('SearchController');
|
||||
Route::type('post')->protect()->get('/search/q')->controller('SearchController@qSearch');
|
||||
|
||||
// Пагинация и главная страница
|
||||
Route::get('/{page?}')->protect()->controller('PostController')->where(['page' => '[0-9]+']);
|
Loading…
Reference in a new issue