Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
💅 chevereto news
Browse files Browse the repository at this point in the history
  • Loading branch information
rodber committed Dec 20, 2021
1 parent 86e50ec commit fb6506d
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 15 deletions.
10 changes: 3 additions & 7 deletions app/install/installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,28 +292,24 @@
'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)) {
continue;
}
$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`;
Expand Down
2 changes: 2 additions & 0 deletions app/lib/classes/class.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ public function __construct()
'moderatecontent_block_rating' => 'a',
'moderatecontent_flag_nsfw' => 'a',
'moderate_uploads' => '', // ,
// 3.20.13
'chevereto_news' => 'a:0:{}',
];

$device_to_columns = [
Expand Down
12 changes: 12 additions & 0 deletions app/lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use G;
use DirectoryIterator;
use Exception;
use Throwable;

if (!defined('access') or !access) {
die('This file cannot be directly accessed.');
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions app/routes/route.dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@
}

$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(),
Expand Down
73 changes: 73 additions & 0 deletions app/themes/Peafowl/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion app/themes/Peafowl/style.min.css

Large diffs are not rendered by default.

35 changes: 28 additions & 7 deletions app/themes/Peafowl/views/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']) . '"';
} ?>>
Expand Down Expand Up @@ -72,19 +72,40 @@ 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>
<span class="display-table-cell vertical-align-middle" style="line-height: 1;">
<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) {
Expand Down

0 comments on commit fb6506d

Please sign in to comment.