fix: restyle pager chips and restore theme ad slots
Replace the loose page-count label with a SaBlog-style 6 / 316 chip, wire inject/stylevar HTML into list and post views, and flush page cache when ads are saved. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -72,7 +72,7 @@ class HomeViewModeTest extends TestCase
|
||||
|
||||
$this->get('/')
|
||||
->assertOk()
|
||||
->assertSee('第 1 /', false)
|
||||
->assertSee('页', false);
|
||||
->assertSee('pagination-info', false)
|
||||
->assertSee('1 /', false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ class SablogImportTest extends TestCase
|
||||
$pdo->exec('CREATE TABLE sablog_comments (commentid INTEGER PRIMARY KEY, articleid INTEGER, author TEXT, url TEXT, dateline INTEGER, content TEXT, ipaddress TEXT, visible INTEGER)');
|
||||
$pdo->exec('CREATE TABLE sablog_links (linkid INTEGER PRIMARY KEY, displayorder INTEGER, name TEXT, url TEXT, note TEXT, visible INTEGER)');
|
||||
$pdo->exec('CREATE TABLE sablog_tags (tagid INTEGER PRIMARY KEY, tag TEXT, usenum INTEGER, aids TEXT)');
|
||||
$pdo->exec('CREATE TABLE sablog_stylevars (stylevarid INTEGER PRIMARY KEY, title TEXT, value TEXT, description TEXT)');
|
||||
$pdo->exec('CREATE TABLE sablog_settings (title TEXT PRIMARY KEY, value TEXT)');
|
||||
$pdo->exec('CREATE TABLE sablog_users (userid INTEGER PRIMARY KEY, username TEXT, password TEXT, logincount INTEGER, loginip TEXT, logintime INTEGER, url TEXT, articles INTEGER, regdateline INTEGER, regip TEXT, groupid INTEGER, lastpost INTEGER)');
|
||||
$pdo->exec('CREATE TABLE sablog_attachments (attachmentid INTEGER PRIMARY KEY, articleid INTEGER, dateline INTEGER, filename TEXT, filetype TEXT, filesize INTEGER, downloads INTEGER, filepath TEXT, thumb_filepath TEXT, thumb_width INTEGER, thumb_height INTEGER, isimage INTEGER)');
|
||||
@@ -69,6 +70,7 @@ class SablogImportTest extends TestCase
|
||||
$pdo->exec("INSERT INTO sablog_links VALUES (1, 0, '友链A', 'https://a.example.com', '', 1)");
|
||||
$pdo->exec("INSERT INTO sablog_tags VALUES (1, 'laravel', 1, '10'), (2, '随笔', 1, '10')");
|
||||
$pdo->exec("INSERT INTO sablog_settings VALUES ('name', '老站名'), ('description', '老描述'), ('templatename', 'default')");
|
||||
$pdo->exec("INSERT INTO sablog_stylevars VALUES (1, 'ad_header', '<div class=\"legacy-ad\">老广告</div>', '')");
|
||||
$pdo->exec("INSERT INTO sablog_attachments VALUES (1, 10, $now, 'photo.jpg', 'image/jpeg', 100, 3, '2020/09/photo.jpg', '', 0, 0, 1), (2, 10, $now, 'archive.zip', 'application/zip', 200, 1, '2020/09/archive.zip', '', 0, 0, 0)");
|
||||
}
|
||||
|
||||
@@ -116,6 +118,7 @@ class SablogImportTest extends TestCase
|
||||
// 设置映射
|
||||
$this->assertSame('老站名', Setting::get('site_name'));
|
||||
$this->assertSame('sablog', Setting::get('active_theme'));
|
||||
$this->assertSame('<div class="legacy-ad">老广告</div>', theme('var', 'ad_header', ''));
|
||||
}
|
||||
|
||||
public function test_import_converts_content_to_markdown(): void
|
||||
|
||||
@@ -57,7 +57,7 @@ class ThemeInjectTest extends TestCase
|
||||
['point' => 'footer', 'title' => '第二条', 'html' => '<div id="inject-2">second</div>', 'sort' => 2, 'enabled' => true],
|
||||
]);
|
||||
|
||||
$html = $this->get('/posts/inject-test.shtml')->getContent();
|
||||
$html = $this->get('/show-'.Post::where('slug', 'inject-test')->value('id').'.shtml')->getContent();
|
||||
|
||||
$pos1 = strpos($html, 'id="inject-1"');
|
||||
$pos2 = strpos($html, 'id="inject-2"');
|
||||
@@ -82,7 +82,7 @@ class ThemeInjectTest extends TestCase
|
||||
['point' => 'post_content_bottom', 'title' => '正文后广告', 'html' => '<div id="post-bottom-ad">BOTTOM</div>', 'sort' => 1, 'enabled' => true],
|
||||
]);
|
||||
|
||||
$html = $this->get('/posts/inject-test.shtml')->getContent();
|
||||
$html = $this->get('/show-'.Post::where('slug', 'inject-test')->value('id').'.shtml')->getContent();
|
||||
|
||||
$this->assertStringContainsString('post-top-ad', $html);
|
||||
$this->assertStringContainsString('post-bottom-ad', $html);
|
||||
@@ -97,4 +97,21 @@ class ThemeInjectTest extends TestCase
|
||||
// theme('var') 直接可用
|
||||
$this->assertSame('<div class="header-ad">头部广告</div>', theme('var', 'ad_header', ''));
|
||||
}
|
||||
|
||||
public function test_content_top_and_stylevars_render_on_home(): void
|
||||
{
|
||||
Setting::set('inject.blocks', [
|
||||
['point' => 'content_top', 'title' => '首页广告', 'html' => '<div id="home-top-ad">首页广告位</div>', 'sort' => 1, 'enabled' => true],
|
||||
]);
|
||||
Setting::set('theme_vars_sablog', [
|
||||
'ad_header' => '<div class="header-ad">头部广告</div>',
|
||||
'huangjinlian' => '<div class="footer-ad">页脚广告</div>',
|
||||
]);
|
||||
|
||||
$this->get('/')
|
||||
->assertOk()
|
||||
->assertSee('首页广告位', false)
|
||||
->assertSee('头部广告', false)
|
||||
->assertSee('页脚广告', false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user