💅 chevereto news

This commit is contained in:
Rodolfo Berrios 2021-12-20 10:34:52 -03:00
parent 86e50ec21c
commit fb6506d439
No known key found for this signature in database
GPG Key ID: D3AAC2481DBDD9FE
7 changed files with 125 additions and 15 deletions

View File

@ -292,13 +292,12 @@ try {
'1.5.0' => null,
'1.5.1' => null,
'1.6.0' => null,
'1.6.1' => [
'chevereto_news' => 'a:0:{}',
],
];
// Settings that must be renamed from NAME to NEW NAME and DELETE old NAME
$settings_rename = [];
// Settings that must be renamed from NAME to NEW NAME and doesn't delete old NAME
$settings_switch = [];
$chv_initial_settings = [];
foreach ($settings_updates as $k => $v) {
if (is_null($v)) {
@ -306,14 +305,11 @@ try {
}
$chv_initial_settings += $v;
}
// Detect 2.X
try {
$is_2X = DB::get('info', ['key' => 'version']) ? true : false;
} catch (Exception $e) {
$is_2X = false;
}
/* Stats query from 3.7.0 up to 3.8.13 */
$stats_query_legacy = 'TRUNCATE TABLE `%table_prefix%stats`;

View File

@ -171,6 +171,8 @@ class Settings
'moderatecontent_block_rating' => 'a',
'moderatecontent_flag_nsfw' => 'a',
'moderate_uploads' => '', // ,
// 3.20.13
'chevereto_news' => 'a:0:{}',
];
$device_to_columns = [

View File

@ -17,6 +17,7 @@ namespace CHV;
use G;
use DirectoryIterator;
use Exception;
use Throwable;
if (!defined('access') or !access) {
die('This file cannot be directly accessed.');
@ -817,6 +818,17 @@ function checkUpdates()
} // Silence
}
function updateCheveretoNews() {
try {
$chevereto_news = G\fetch_url('https://blog.chevereto.com/feed.json');
$chevereto_news = json_decode($chevereto_news)->items;
Settings::update(['chevereto_news' => serialize($chevereto_news)]);
} catch(Throwable $e) {
$chevereto_news = [];
}
return $chevereto_news;
}
function obfuscate($string)
{
$len = strlen($string);

View File

@ -112,6 +112,12 @@ $route = function ($handler) {
}
$db = CHV\DB::getInstance();
$chevereto_news = unserialize(CHV\Settings::get('chevereto_news'));
if(!is_array($chevereto_news) || $chevereto_news === []) {
$chevereto_news = CHV\updateCheveretoNews();
}
$handler::setVar('chevereto_news', $chevereto_news);
$chv_version = [
'files' => G\get_app_version(),

View File

@ -2390,4 +2390,77 @@ body.full--wh {
body#index.landing [data-action=top-bar-tone] {
display: none;
}
.card-wrapper {
height: 175px;
overflow-y: hidden;
overflow-x: auto;
}
.card-slider {
width: calc(310px * 8);
}
.card-container {
width: 300px;
height: 200px;
display: block;
float: left;
margin: 0 5px;
}
.card-container:first-child {
margin-left: 0;
}
.card-container:last-child {
margin-right: 0;
}
.card {
width: 100%;
position: relative;
}
.card a {
text-decoration: none;
}
.card-header-image {
width: 100%;
height: 150px;
overflow: hidden;
border-radius: 1em;
display: block;
background-size: cover;
background-position: center;
}
.card-header-image-mask {
width: 100%;
height: 100%;
display: block;
background-color: rgba(0, 0, 0, 0);
}
.card-header-image:hover .card-header-image-mask {
background-color: rgba(35, 168, 224, .8);
}
.card-text {
color: #FFF;
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 80%;
text-shadow: 2px 2px 4px rgba(0, 0, 0, .35);
}
.card-text h3 {
font-weight: bold;
font-size: 1.6em;
margin-bottom: 5px;
}

File diff suppressed because one or more lines are too long

View File

@ -39,7 +39,7 @@ function get_docs_link($key, $subject)
<p><?php _se("Make sure that you address this issue as the system relies on accurate IP detections to provide basic functionalities and to protect against spam, flooding, and brute force attacks."); ?></p>
</div>
<div class="dashboard-group">
<div class="overflow-auto text-align-center margin-top-20">
<div class="overflow-auto text-align-center margin-top-20 margin-bottom-40">
<a href="<?php echo G\get_base_url('dashboard/images'); ?>" class="stats-block c6 fluid-column display-inline-block" <?php if (get_totals()['images'] > 999999) {
echo ' rel="tooltip" data-tipTip="top" title="' . number_format(get_totals()['images']) . '"';
} ?>>
@ -72,6 +72,33 @@ function get_docs_link($key, $subject)
</div>
</div>
<div class="header header-tabs no-select">
<h2><i class="icon icon-rss"></i> <?php _se('%s News', 'Chevereto'); ?></h2>
</div>
<div class="card-wrapper margin-bottom-40">
<div class="card-slider">
<?php foreach(array_slice(get_chevereto_news(), 0, 8) as $k => $v) {
echo strtr('<article class="card-container">
<div class="card">
<a class="card-header-image" href="%url%" target="_blank" style="background-image: url(%image%);">
<span class="animate card-header-image-mask"></span>
<span class="card-text">
<h3>%title%</h3>
<span>%summary%</span>
</span>
</a>
</div>
</article>' . "\n", [
'%url%' => $v->url,
'%image%' => $v->image,
'%title%' => $v->title,
'%summary%' => $v->summary,
]);
} ?>
</div>
</div>
<ul class="tabbed-content-list table-li margin-top-20">
<li>
<span class="c6 display-table-cell padding-right-10">GitHub<span style="opacity: 0;">:</span></span>
@ -79,12 +106,6 @@ function get_docs_link($key, $subject)
<a class="github-button" href="https://github.com/rodber/chevereto-free/subscription" data-icon="octicon-eye" data-size="large" data-show-count="true" aria-label="Watch rodber/chevereto-free on GitHub">Watch</a>
<a class="github-button" href="https://github.com/rodber/chevereto-free" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star rodber/chevereto-free on GitHub">Star</a>
</span>
<div class="highlight padding-5 margin-top-10 margin-bottom-10">Chevereto-Free project ownership will be <b>transferred</b> to <a href="https://github.com/rodber" target="_blank">rodber</a> on <b>2021-10</b>.
<ul class="list-style-type-disc padding-left-20">
<li>The Chevereto organization won't be longer involved with the development of this project.</li>
<li>The project repository will be available at <a href="https://github.com/rodber/chevereto-free" target="_blank">rodber/chevereto-free</a>.</li>
</ul>
</div>
</li>
<?php
foreach (get_system_values() as $v) {