Skip to content

Commit 25b52d9

Browse files
boneliferclaude
andauthored
Update the NV Newspage screenshots for its new layout (#34)
Adds a fourth news topic opening with a picture the script draws with GD (and deletes afterwards), turns on the lead image for the main shots, takes the single news item as the admin, and adds a shot filtered by forum. The cleanup list now removes files as well as folders. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 4ab1e0b commit 25b52d9

2 files changed

Lines changed: 36 additions & 15 deletions

File tree

‎phpbb-test-board/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Saves PNG screenshots of an extension's or style's pages with [Playwright](https
111111

112112
`phpbbmodders/knowledgebase` makes its own categories, articles (live, waiting for review, with a revision, and a draft) and forum questions, so a board search for `backup` shows its block; `--seed` with seed-forum's standard fixtures adds members to write them. Its two ACP pages are taken in full, so a new setting is not cut off.
113113

114-
`phpbbmodders/newspage` replaces the board's welcome topic with three example news topics and makes that forum the news forum, with poster information and post buttons off. It saves the news page, one news item, the ACP settings (in full) and the news page on a phone, then the news page three more times: with poster information and post buttons on, shortened to 120 characters, and without the filters.
114+
`phpbbmodders/newspage` replaces the board's welcome topic with four example news topics, the last one opening with a picture the script draws (and deletes afterwards), and makes that forum the news forum. It saves the news page with the first image above the text and without poster information or post buttons, one news item as the admin, the ACP settings (in full), the news page on a phone and filtered by forum, then the news page with poster information and post buttons on, shortened to 120 characters, and without the filters.
115115

116116
For example, ProMinoDeux's screenshots:
117117

‎phpbb-test-board/screenshots.py‎

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(self, board: Board, browser: Browser, out_dir: Path) -> None:
5050
self.out_dir = out_dir
5151
self.saved: list = []
5252
self.failed: list = []
53-
self.cleanup: list = [] # paths to delete once the screenshots are taken
53+
self.cleanup: list = [] # files and folders to delete once the screenshots are taken
5454
self._admin_sid = ""
5555
self._admin_cookies: list = []
5656
self._admin_agent = ""
@@ -862,13 +862,27 @@ def hide_who_is_online(p) -> None:
862862
("Scheduled maintenance this weekend",
863863
"The board will be read-only for about an hour on Saturday morning while we move to a new server. "
864864
"Posts made just before the move are kept."),
865+
("Photos from the spring walk",
866+
"[img]{IMAGE}[/img]\n\nThanks to everyone who came along on the spring walk. We had clear skies all day, "
867+
"and twelve members made it to the top of the hill.\n\nPost your own photos in the members' area, and "
868+
"let us know where we should go next time."),
865869
]
866870

867871
NEWSPAGE_SEED = r"""
868872
require_once $phpbb_root_path . 'includes/functions_posting.php';
869873
require_once $phpbb_root_path . 'includes/functions_admin.php';
870874
// the install's welcome topic is in the same forum; the news page shows only the example news
871875
delete_topics('forum_id', [2]);
876+
// a picture for the last news item, drawn here so no image file has to ship with the tool
877+
$w = 1200; $h = 500;
878+
$img = imagecreatetruecolor($w, $h);
879+
for ($y = 0; $y < $h; $y++) {
880+
imageline($img, 0, $y, $w, $y, imagecolorallocate($img, 40 + (int) (60 * $y / $h), 110 + (int) (60 * $y / $h), 170 + (int) (40 * $y / $h)));
881+
}
882+
imagefilledellipse($img, 910, 150, 180, 180, imagecolorallocate($img, 250, 210, 120));
883+
imagefilledpolygon($img, [0, 500, 300, 250, 560, 500], imagecolorallocate($img, 40, 90, 70));
884+
imagefilledpolygon($img, [380, 500, 760, 200, 1200, 500], imagecolorallocate($img, 60, 120, 90));
885+
imagepng($img, $phpbb_root_path . 'images/newspage-example.png');
872886
$news = json_decode(%s, true);
873887
$keep = $user->data;
874888
$user->data = array_merge($keep, ['user_id' => 2, 'username' => 'admin', 'user_ip' => '127.0.0.1',
@@ -898,30 +912,34 @@ def hide_who_is_online(p) -> None:
898912
def shots_newspage(board: Board, shoot: Shooter, args: argparse.Namespace) -> None:
899913
"""phpbbmodders/newspage: the news page, one news item and the ACP settings.
900914
901-
Replaces the install's welcome topic in the board's first forum with three
902-
news topics and makes it the news forum. Poster information and the post
903-
buttons are turned off, so the news text stands out; the other settings
904-
stay at their defaults. Three more shots of the news page show it with
905-
poster information and post buttons on (as the admin, who sees every
906-
button), with the news shortened to 120 characters, and without the
907-
forum and date filters.
915+
Replaces the install's welcome topic in the board's first forum with four
916+
news topics, the last one opening with a picture, and makes it the news
917+
forum. The main shots show the news with the first image above the text and
918+
without poster information or post buttons. More shots of the news page
919+
show it with poster information and post buttons on (as the admin, who
920+
sees every button), shortened to 120 characters without the lead image,
921+
filtered by forum, and without the filters.
908922
"""
909-
out = board.php(NEWSPAGE_SEED % php_string(json.dumps(NEWSPAGE_NEWS)), check=True)
923+
# The picture is served by the screenshot server, so the BBCode needs its address
924+
news = [(subject, text.replace("{IMAGE}", f"{board.base}/images/newspage-example.png")) for subject, text in NEWSPAGE_NEWS]
925+
out = board.php(NEWSPAGE_SEED % php_string(json.dumps(news)), check=True)
926+
shoot.cleanup.append(board.root / "images" / "newspage-example.png")
910927
topics = json.loads(out.split("NEWS-TOPICS:")[1].split()[0])
911-
set_config(board, {"news_forums": "2", "news_user_info": "0", "news_post_buttons": "0"})
928+
set_config(board, {"news_forums": "2", "news_user_info": "0", "news_post_buttons": "0", "news_lead_image": "1"})
912929

913930
shoot.shot("newspage-news", "app.php/news")
914-
shoot.shot("newspage-single", f"app.php/news/{topics[0]}")
931+
shoot.shot("newspage-single", f"app.php/news/{topics[-1]}?sid={{sid}}", admin=True)
915932
shoot.shot("newspage-acp-settings", "adm/index.php?i=-phpbbmodders-newspage-acp-main_module&mode=settings&sid={sid}",
916933
admin=True, full_page=True)
917934
shoot.shot("newspage-news-phone", "app.php/news", phone=True)
935+
shoot.shot("newspage-news-filtered", "app.php/news/category/2")
918936

919937
# The same page with other settings, one change at a time
920938
set_config(board, {"news_user_info": "1", "news_post_buttons": "1"})
921939
shoot.shot("newspage-news-full", "app.php/news?sid={sid}", admin=True)
922-
set_config(board, {"news_user_info": "0", "news_post_buttons": "0", "news_char_limit": "120"})
940+
set_config(board, {"news_user_info": "0", "news_post_buttons": "0", "news_char_limit": "120", "news_lead_image": "0"})
923941
shoot.shot("newspage-news-shortened", "app.php/news")
924-
set_config(board, {"news_char_limit": "500", "news_cat_show": "0", "news_archive_show": "0"})
942+
set_config(board, {"news_char_limit": "500", "news_lead_image": "1", "news_cat_show": "0", "news_archive_show": "0"})
925943
shoot.shot("newspage-news-no-filters", "app.php/news")
926944

927945

@@ -1022,7 +1040,10 @@ def main() -> int:
10221040
finally:
10231041
browser.close()
10241042
for path in shooter.cleanup:
1025-
shutil.rmtree(path, ignore_errors=True)
1043+
if Path(path).is_dir():
1044+
shutil.rmtree(path, ignore_errors=True)
1045+
else:
1046+
Path(path).unlink(missing_ok=True)
10261047
errors = board.php_errors()
10271048
if errors:
10281049
print(f" [FAIL] PHP errors logged: {errors[0][:200]}")

0 commit comments

Comments
 (0)