Fembooru changes

This commit is contained in:
James Shiffer 2022-05-14 16:44:50 -07:00
parent c1068f1b2b
commit 7040b1b8e5
16 changed files with 167 additions and 1668 deletions

View File

@ -6,10 +6,6 @@
"minimum-stability" : "dev",
"repositories" : [
{
"type": "composer",
"url": "https://asset-packagist.org"
},
{
"type" : "package",
"package" : {
@ -25,18 +21,19 @@
],
"require" : {
"php" : ">=7.3",
"php" : "^7.3",
"ext-pdo": "*",
"ext-json": "*",
"ext-fileinfo": "*",
"flexihash/flexihash" : "^2.0.0",
"ifixit/php-akismet" : "1.*",
"google/recaptcha" : "~1.1",
"dapphp/securimage" : "3.6.*",
"shish/eventtracer-php" : "^1.0.0",
"shish/ffsphp" : "0.0.*",
"shish/microcrud" : "^1.0.0",
"shish/microhtml" : "^1.0.0",
"shish/eventtracer-php" : "^2.0.0",
"shish/ffsphp" : "^1.0.0",
"shish/microcrud" : "^2.0.0",
"shish/microhtml" : "^2.0.0",
"enshrined/svg-sanitize" : "0.13.*",
"bower-asset/jquery" : "1.12.*",
@ -46,8 +43,7 @@
},
"require-dev" : {
"phpunit/phpunit" : "8.*"
},
},
"suggest": {
"ext-memcache": "memcache caching",
@ -62,5 +58,10 @@
"ext-zlib": "anti-spam",
"ext-xml": "some extensions",
"ext-gd": "GD-based thumbnailing"
}
},"replace": {
"bower-asset/jquery": ">=1.11.0",
"bower-asset/inputmask": ">=3.2.0",
"bower-asset/punycode": ">=1.3.0",
"bower-asset/yii2-pjax": ">=2.0.0"
}
}

1636
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -404,7 +404,6 @@ class BasePage
$js_latest = $config_latest;
$js_files = array_merge(
[
"vendor/bower-asset/jquery/dist/jquery.min.js",
"vendor/bower-asset/jquery-timeago/jquery.timeago.js",
"vendor/bower-asset/js-cookie/src/js.cookie.js",
"ext/static_files/modernizr-3.3.1.custom.js",

View File

@ -213,6 +213,27 @@ class Image
);
}
/**
* Counts consecutive days of image uploads
*/
public static function count_upload_streak(): int
{
$now = date_create();
$last_date = $now;
foreach (self::find_images_iterable() as $img) {
$next_date = date_create($img->posted);
if (date_diff($next_date, $last_date)->days > 0) {
break;
}
$last_date = $next_date;
}
if ($last_date === $now) {
return 0;
}
$diff_d = ($now->getTimestamp() - $last_date->getTimestamp()) / 86400;
return (int)ceil($diff_d) + 1;
}
/**
* Count the number of image results for a given search
*

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

@ -5,6 +5,20 @@ class Home extends Extension
/** @var HomeTheme */
protected $theme;
private $femDimensions = array(
array(23, 64),
array(14, 86),
array(31, 63),
array(37, 100)
);
private $femTags = array(
"Hatsune_Miku",
"Monika",
"Violet_Parr",
"Keith_Kogane"
);
public function onPageRequest(PageRequestEvent $event)
{
global $config, $page;
@ -34,6 +48,27 @@ class Home extends Extension
$event->panel->add_block($sb);
}
private function addCountToBlankImage($charId, $digit)
{
$font = realpath('ext/home/vga.ttf');
$file = "ext/home/counters/femcounter/$charId.png";
$img = imagecreatefrompng($file);
$black = imagecolorallocate($img, 0, 0, 0);
$x = $this->femDimensions[$charId][0];
$y = $this->femDimensions[$charId][1];
imagettftext($img, 20, 0, $x, $y + 20, $black, $font, $digit);
imagetruecolortopalette($img, true, 16);
imagesavealpha($img, true);
imagecolortransparent($img, imagecolorat($img, 0, 0));
ob_start();
imagegif($img);
$image_data = ob_get_contents();
ob_end_clean();
$data = base64_encode($image_data);
imagedestroy($img);
return $data;
}
private function get_body()
{
@ -48,14 +83,23 @@ class Home extends Extension
$counter_dir = $config->get_string('home_counter', 'default');
$total = Image::count_images();
$streak = Image::count_upload_streak();
$strtotal = "$total";
$num_comma = number_format($total);
$streak_comma = number_format($streak);
$counter_text = "";
$length = strlen($strtotal);
for ($n=0; $n<$length; $n++) {
$cur = $strtotal[$n];
$counter_text .= " <img alt='$cur' src='$base_href/ext/home/counters/$counter_dir/$cur.gif' /> ";
if ($counter_dir === 'femcounter') {
$charId = $n % 4;
$base64url = $this->addCountToBlankImage($charId, $cur);
$tag = $this->femTags[$charId];
$counter_text .= " <a href='$base_href/post/list/$tag/1'><img alt='$cur' title='$tag' src='data:image/gif;base64,$base64url' /></a> ";
} else {
$counter_text .= " <img alt='$cur' src='$base_href/ext/home/counters/$counter_dir/$cur.gif' /> ";
}
}
// get the homelinks and process them
@ -74,6 +118,6 @@ class Home extends Extension
$main_links = format_text($main_links);
$main_text = $config->get_string('home_text', '');
return $this->theme->build_body($sitename, $main_links, $main_text, $contact_link, $num_comma, $counter_text);
return $this->theme->build_body($sitename, $main_links, $main_text, $contact_link, $num_comma, $counter_text, $streak_comma);
}
}

View File

@ -5,7 +5,7 @@ div#front-page div#links a {margin: 0 0.5em;}
div#front-page li {list-style-type: none; margin: 0;}
@media (max-width: 800px) {
div#front-page h1 {font-size: 3em; margin-top: 0.5em; margin-bottom: 0.5em;}
#counter {display: none;}
/*#counter {display: none;}*/
}
div#front-page > #search > form { margin: 0 auto; }

BIN
ext/home/vga.ttf Normal file

Binary file not shown.

View File

@ -1,7 +1,7 @@
<table class="headbox">
<tr>
<td colspan="4" id="big-logo">
<a class="vis-desktop" href="//rule34.paheal.net/post/list"><img alt="logo" src="//rule34.paheal.net/themes/rule34v2/rule34_logo_top.png" style="width: 240px; height: 104px;"/></a>
<a class="vis-desktop" href="//fembooru.jp/post/list"><img alt="logo" src="//fembooru.jp/themes/rule34v2/Fembooru.gif" style="width: 240px; margin:15px 0; image-rendering:crisp-edges;"/></a>
</td>
</tr>
@ -11,7 +11,7 @@
<a style="font-size: 2em;" onclick="toggleNav();">&nbsp;Sidebar&nbsp;</a>
</td>
<td id="mini-logo">
<a class="vis-mobile" href="//rule34.paheal.net/post/list"><img alt="logo" src="//rule34.paheal.net/themes/rule34v2/rule34_logo_top.png" style="height: 34px;"/></a>
<a class="vis-mobile" href="//fembooru.jp/post/list"><img alt="logo" src="//fembooru.jp/themes/rule34v2/Fembooru.gif" style="height: 34px; margin:10px 0; image-rendering:crisp-edges;"/></a>
</td>
<td>
<input name='search' size="45" type='text' placeholder='Search' autocomplete='off' class='autocomplete_tags' value="<?=$query;?>"/>
@ -28,54 +28,27 @@
<div id="menuh">
<ul>
<li><a href="//rule34.paheal.net/post/list" class="top_parent">Main &#9660;</a>
<li><a href="//fembooru.jp/post/list" class="top_parent">Main &#9660;</a>
<ul>
<li><a href="//rule34.paheal.net/post/list" class="sub_option">Home page</a></li>
<li><a href="//rule34.paheal.net/comment/list" class="sub_option">Comments</a></li>
<li><a href="//rule34.paheal.net/tags" class="sub_option">Tags</a></li>
<li><a href="//rule34.paheal.net/upload" class="sub_option">Upload</a></li>
</ul>
</li>
</ul>
<!--<ul class="header-sites">
<li><a href="#" class="top_parent">Sites</a>
<ul>
<li><a href="//rule34.paheal.net/" class="sub_option">Rule #34</a></li>
<li><a href="http://rule63.paheal.net/" class="sub_option">Rule #63</a></li>
<li><a href="http://cosplay.paheal.net/" class="sub_option">Cosplay</a></li>
<li><a href="//rule34c.paheal.net/" class="sub_option">Rule #34c</a></li>
</ul>
</li>
</ul>-->
<ul>
<li><a href="#" class="top_parent">Community &#9660;</a>
<ul>
<!--<li><a href="http://forum.paheal.net" class="sub_option">Forum</a></li>-->
<li><a href="//rule34.paheal.net/wiki/friends" class="parent">Friends of paheal</a>
<li><a href="//rule34.paheal.net/wiki/DNP" class="parent">DNP List</a>
<li><a href="#" class="parent">Chat</a>
<ul>
<li><a href="irc://irc.rizon.net/rule34" class="sub_option">irc.rizon.net/rule34</a></li>
<li><a href="http://widget.mibbit.com/?server=irc.rizon.net&nick=Anon%3F%3F%3F&channel=%23rule34" target="new" class="sub_option">Web Chat</a></li>
</ul>
</li>
<li><a href="//fembooru.jp/post/list" class="sub_option">Home page</a></li>
<li><a href="//fembooru.jp/comment/list" class="sub_option">Comments</a></li>
<li><a href="//fembooru.jp/tags" class="sub_option">Tags</a></li>
<li><a href="//fembooru.jp/upload" class="sub_option">Upload</a></li>
</ul>
</li>
</ul>
<ul>
<li><a href="//rule34.paheal.net/post/list" class="top_parent">Help &#9660;</a>
<li><a href="//fembooru.jp/post/list" class="top_parent">Help &#9660;</a>
<ul>
<li><a href="//rule34.paheal.net/wiki/rules" class="sub_option">Site rules</a></li>
<li><a href="//rule34.paheal.net/wiki/faq" class="sub_option">F.A.Q.</a></li>
<li><a href="//rule34.paheal.net/wiki/tagging" class="sub_option">Tagging Guide</a></li>
<li><a href="//rule34.paheal.net/wiki/staff" class="sub_option">Staff</a></li>
<li><a href="//fembooru.jp/wiki/rules" class="sub_option">Site rules</a></li>
<li><a href="//fembooru.jp/wiki/faq" class="sub_option">F.A.Q.</a></li>
<li><a href="//fembooru.jp/wiki/tagging" class="sub_option">Tagging Guide</a></li>
<li><a href="//fembooru.jp/wiki/staff" class="sub_option">Staff</a></li>
<li><a href="#" class="parent">Contact</a>
<ul>
<li><a href="mailto:staff@paheal.net" class="sub_option">Staff</a></li>
<li><a href="mailto:webmaster@shishnet.org" class="sub_option">Programmer</a></li>
<li><a href="mailto:staff@fembooru.jp" class="sub_option">Staff</a></li>
<li><a href="mailto:webmaster@fembooru.jp" class="sub_option">Programmer</a></li>
</ul>
</li>
</ul>
@ -83,7 +56,7 @@
</ul>
<ul>
<li><a class="menu top_parent" href="//rule34.paheal.net/wiki/Notes">ANNOUNCEMENTS</a></li>
<li><a class="menu top_parent" href="//fembooru.jp/wiki/Notes">ANNOUNCEMENTS</a></li>
</ul>
</div>

View File

@ -15,6 +15,7 @@ class CustomHomeTheme extends HomeTheme
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="theme-color" content="#7EB977">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
$hh
<style>
div#front-page h1 {font-size: 4em; margin-top: 2em; margin-bottom: 0; text-align: center; border: none; background: none; box-shadow: none; -webkit-box-shadow: none; -moz-box-shadow: none;}
@ -24,7 +25,7 @@ class CustomHomeTheme extends HomeTheme
div#front-page li {list-style-type: none; margin: 0;}
@media (max-width: 800px) {
div#front-page h1 {font-size: 3em; margin-top: 0.5em; margin-bottom: 0.5em;}
#counter {display: none;}
/*#counter {display: none;}*/
}
</style>
</head>
@ -36,12 +37,13 @@ EOD
);
}
public function build_body(string $sitename, string $main_links, string $main_text, string $contact_link, $num_comma, string $counter_text)
public function build_body(string $sitename, string $main_links, string $main_text, string $contact_link, $num_comma, string $counter_text, string $streak_comma = "0")
{
$main_links_html = empty($main_links) ? "" : "<div class='space' id='links'>$main_links</div>";
$message_html = empty($main_text) ? "" : "<div class='space' id='message'>$main_text</div>";
$counter_html = empty($counter_text) ? "" : "<div class='space' id='counter'>$counter_text</div>";
$contact_link = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a> &ndash;";
$streak_html = $streak_comma === "0" ? "" : "Upload streak: $streak_comma days 🔥 &ndash;";
$search_html = "
<div class='space' id='search'>
<form action='".make_link("post/list")."' method='GET'>
@ -53,14 +55,18 @@ EOD
";
return "
<div id='front-page'>
<h1><a style='text-decoration: none;' href='".make_link()."'><span>$sitename</span></a></h1>
<h1>
<a style='text-decoration: none;' href='".make_link()."'>
<img style='width: 360px; margin:15px 0; image-rendering:crisp-edges;' alt='$sitename' src='".make_link("themes/rule34v2/Fembooru.gif")."' />
</a>
</h1>
$main_links_html
$search_html
$message_html
$counter_html
<div class='space' id='foot'>
<!-- JuicyAds v3.1 -->
<!-- JuicyAds v3.1
<script type='text/javascript' data-cfasync='false' async src='https://poweredby.jads.co/js/jads.js'></script>
<ins id='825625' data-width='908' data-height='270'></ins>
<script type='text/javascript' data-cfasync='false' async>(adsbyjuicy = window.adsbyjuicy || []).push({'adzone':825625});</script>
@ -68,6 +74,7 @@ EOD
<small><small>
$contact_link Serving $num_comma posts &ndash;
$streak_html
Running <a href='http://code.shishnet.org/shimmie2/'>Shimmie2</a>
</small></small>
</div>

View File

@ -53,8 +53,8 @@ class Page extends BasePage
<meta name="viewport" content="width=1024">
<meta name="theme-color" content="#7EB977">
<link rel="stylesheet" href="$data_href/themes/$theme_name/menuh.css" type="text/css">
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
$header_html
<script defer src="https://unpkg.com/webp-hero@0.0.0-dev.21/dist-cjs/polyfills.js"></script>
<script defer src="https://unpkg.com/webp-hero@0.0.0-dev.21/dist-cjs/webp-hero.bundle.js"></script>
<script>
@ -80,9 +80,6 @@ EOD;
<nav>
$left_block_html
<p>
<a href="//whos.amung.us/show/4vcsbthd"><img src="//whos.amung.us/widget/4vcsbthd.png" style="display:none" alt="web counter" /></a>
</p>
</nav>
<article>
@ -94,16 +91,15 @@ EOD;
<footer>
<span style="font-size: 12px;">
<a href="http://rule34.paheal.net/wiki/Terms%20of%20use">Terms of use</a>
<a href="http://fembooru.jp/wiki/Terms%20of%20use">Terms of use</a>
!!!
<a href="http://rule34.paheal.net/wiki/Privacy%20policy">Privacy policy</a>
<a href="http://fembooru.jp/wiki/Privacy%20policy">Privacy policy</a>
!!!
<a href="http://rule34.paheal.net/wiki/2257">18 U.S.C. &sect;2257</a><br />
<a href="http://fembooru.jp/wiki/2257">18 U.S.C. &sect;2257</a><br />
</span>
<hr />
<span style="font-size: 12px;">
BTC: <b>193gutWtgirF7js14ivcXfnfQgXv9n5BZo</b>
ETH: <b>0x68B88a00e69Bde88E9db1b9fC10b8011226e26aF</b>
LINK: <b>9ffc8053E26E1621F85F50Cc260fb3Fc772cd24F</b>
</span>
<hr />
<br>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

View File

@ -17,7 +17,7 @@ class CustomUploadTheme extends UploadTheme
{
parent::display_page($page);
$html = "
<a href='//rule34.paheal.net/wiki/tagging'>Tagging Guide</a>
<a href='//fembooru.jp/wiki/tagging'>Tagging Guide</a>
";
$page->add_block(new Block(null, $html, "main", 19));
}
@ -25,6 +25,12 @@ class CustomUploadTheme extends UploadTheme
protected function build_upload_block(): string
{
$url = make_link("upload");
return "<a href='$url' style='font-size: 2em; display: block;'>Upload</a>";
$streak = Image::count_upload_streak();
$streak_comma = number_format($streak);
$html = "<a href='$url' style='font-size: 2em; display: block;'>Upload</a>";
if ($streak > 0) {
$html .= "Current streak: $streak_comma days 🔥";
}
return $html;
}
}