Skip to content

Commit ad07da5

Browse files
authored
Merge branch 'main' into meta-description
2 parents 72a4a90 + 8838eff commit ad07da5

File tree

119 files changed

+12206
-3036
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+12206
-3036
lines changed

.github/workflows/deploy-site.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ on:
88
jobs:
99
deploy:
1010
name: Deploy website
11-
runs-on: ubuntu-latest
11+
runs-on: "ubuntu-22.04"
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@main
1515

1616
- name: Setup Node
17-
uses: actions/setup-node@v2
17+
uses: actions/setup-node@v4
1818
with:
19-
node-version: 16
19+
node-version: 20
2020

2121
- name: Install asset deps
2222
run: npm install
@@ -27,7 +27,7 @@ jobs:
2727
- name: Setup PHP
2828
uses: shivammathur/setup-php@v2
2929
with:
30-
php-version: 8.0
30+
php-version: 8.3
3131
extensions: mbstring, intl, readline
3232
tools: composer:v2
3333

.github/workflows/issue-roundup.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: PHP Core Roundup
2+
on:
3+
schedule:
4+
- cron: 0 10 25 * *
5+
6+
jobs:
7+
create_issue:
8+
name: Create an issue with roundup checklist
9+
runs-on: "ubuntu-22.04"
10+
permissions:
11+
issues: write
12+
steps:
13+
- name: Create issue
14+
uses: imjohnbo/issue-bot@v3.4.3
15+
with:
16+
assignees: "Ayesh, saundefined, pronskiy"
17+
labels: "roundup"
18+
title: "Roundup next"
19+
body: |
20+
- [ ] Prepare draft PR
21+
- [ ] Send to #general for review
22+
- [ ] Prepare tweet text
23+
- [ ] Publish blog post
24+
- [ ] Post announcements
25+
- [ ] Twitter
26+
- [ ] LinkedIn
27+
- [ ] Mastodon
28+
- [ ] Send out email newsletter
29+
30+
pinned: false
31+
close-previous: false
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/netlify.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Build and Deploy to Netlify
2+
on:
3+
pull_request_target:
4+
jobs:
5+
build:
6+
runs-on: "ubuntu-22.04"
7+
if: github.repository_owner == 'ThePHPF'
8+
steps:
9+
- uses: actions/checkout@v4
10+
with:
11+
ref: "refs/pull/${{ github.event.number }}/merge"
12+
13+
- name: Setup Node
14+
uses: actions/setup-node@v4
15+
with:
16+
node-version: 20
17+
18+
- name: Update Image Version in the related HelmChart values.yaml
19+
uses: fjogeleit/yaml-update-action@main
20+
with:
21+
valueFile: 'app/config/sculpin_site_prod.yml'
22+
propertyPath: 'url'
23+
value: https://deploy-pr-${{ github.event.number }}--thephpfoundation.netlify.app
24+
commitChange: false
25+
updateFile: true
26+
27+
- name: Install asset deps
28+
run: npm install
29+
30+
- name: Build production assets
31+
run: npx tailwind -i assets/css/app.css -o source/assets/css/app.css --minify
32+
33+
- name: Setup PHP
34+
uses: shivammathur/setup-php@v2
35+
with:
36+
php-version: '8.3'
37+
extensions: mbstring, intl, readline
38+
tools: composer:v2
39+
40+
- name: Install PHP deps
41+
uses: ramsey/composer-install@v2
42+
43+
- name: Build production site
44+
run: ./vendor/bin/sculpin generate --env=prod
45+
46+
- name: Deploy to Netlify
47+
uses: nwtgck/actions-netlify@v1.2
48+
with:
49+
production-deploy: false
50+
publish-dir: './output_prod'
51+
github-token: ${{ secrets.GITHUB_TOKEN }}
52+
deploy-message: "Deploy from GitHub Actions"
53+
enable-pull-request-comment: true
54+
overwrites-pull-request-comment: true
55+
enable-commit-comment: false
56+
alias: deploy-pr-${{ github.event.number }}
57+
env:
58+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
59+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
60+
timeout-minutes: 1

.github/workflows/twitter.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
on: [push, pull_request]
2+
name: Twitter, together!
3+
jobs:
4+
preview:
5+
name: Preview
6+
runs-on: "ubuntu-22.04"
7+
if: github.event_name == 'pull_request'
8+
steps:
9+
- uses: twitter-together/action@v3
10+
env:
11+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
tweet:
13+
name: Tweet
14+
runs-on: "ubuntu-22.04"
15+
environment: thephpf
16+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
17+
steps:
18+
- name: checkout main
19+
uses: actions/checkout@v3
20+
- name: Tweet
21+
uses: twitter-together/action@v3
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
25+
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
26+
TWITTER_API_KEY: ${{ secrets.TWITTER_API_KEY }}
27+
TWITTER_API_SECRET_KEY: ${{ secrets.TWITTER_API_SECRET_KEY }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
/node_modules/
77
/source/assets/css/
88
/vendor/
9+
/.env

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ The site
2929

3030
To develop the website, you will need:
3131

32-
- PHP 7.3 or later
32+
- PHP 8.3 or later
3333
- Composer
34-
- Node 14 or 16 with NPM
34+
- Node 20 with NPM
3535

3636
### Installing dependencies
3737

app/SculpinKernel.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use App\Bundles\AtomFeedGeneratorBundle\SculpinAtomFeedGeneratorBundle;
4+
use App\Bundles\MermaidBundle\SculpinMermaidBundle;
35
use App\Bundles\SharingImageGeneratorBundle\SculpinSharingImageGeneratorBundle;
46
use Sculpin\Bundle\SculpinBundle\HttpKernel\AbstractKernel;
57

@@ -8,7 +10,9 @@ class SculpinKernel extends AbstractKernel
810
protected function getAdditionalSculpinBundles(): array
911
{
1012
return [
11-
SculpinSharingImageGeneratorBundle::class
13+
SculpinAtomFeedGeneratorBundle::class,
14+
SculpinSharingImageGeneratorBundle::class,
15+
SculpinMermaidBundle::class,
1216
];
1317
}
14-
}
18+
}

app/src/Blog/Tag.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44

55
class Tag
66
{
7-
public const ALLOWED_TAGS = [
7+
public const array ALLOWED_TAGS = [
88
'interview' => 'Interview',
99
'roundup' => 'PHP Roundup',
10-
'update' => 'The PHP Foundation Update',
10+
'update' => 'Update',
11+
'team' => 'Team',
12+
'report' => 'Report',
13+
'news' => 'News',
1114
];
12-
}
15+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?php
2+
3+
namespace App\Bundles\AtomFeedGeneratorBundle;
4+
5+
use App\Sitemap\Author;
6+
use App\Sitemap\Entry;
7+
use App\Sitemap\SitemapGenerator;
8+
use Dflydev\DotAccessConfiguration\Configuration;
9+
use Sculpin\Core\Event\SourceSetEvent;
10+
use Sculpin\Core\Sculpin;
11+
use Sculpin\Core\Source\FileSource;
12+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
13+
use Symfony\Component\Filesystem\Filesystem;
14+
15+
class AtomFeedGenerator implements EventSubscriberInterface
16+
{
17+
private Configuration $configuration;
18+
19+
public function __construct(Configuration $configuration)
20+
{
21+
$this->configuration = $configuration;
22+
}
23+
24+
public static function getSubscribedEvents(): array
25+
{
26+
return [
27+
Sculpin::EVENT_AFTER_RUN => 'afterRun',
28+
];
29+
}
30+
31+
public function afterRun(SourceSetEvent $sourceSetEvent): void
32+
{
33+
$sourceSet = $sourceSetEvent->sourceSet();
34+
35+
$env = $this->configuration->get('env') ?? 'dev';
36+
37+
$filesystem = new Filesystem();
38+
if (!$filesystem->exists("output_$env/rss/")) {
39+
$filesystem->mkdir("output_$env/rss/");
40+
}
41+
42+
$entries = [];
43+
44+
/** @var FileSource $source */
45+
foreach ($sourceSet->allSources() as $source) {
46+
if ($source->isGenerated()) {
47+
continue;
48+
}
49+
50+
$data = $source->data();
51+
52+
if ($source->file()->getExtension() !== 'md') {
53+
continue;
54+
}
55+
56+
if (!$data->get('author')) {
57+
continue;
58+
}
59+
60+
$authors = [];
61+
if ($name = $data->get('author.name')) {
62+
$authors[] = new Author($name, $data->get('author.url'));
63+
} else {
64+
foreach ($data->get('author') as $author) {
65+
$authors[] = new Author($author['name'], $author['url']);
66+
}
67+
}
68+
69+
foreach ($authors as $author) {
70+
$slug = $this->slug($author->name);
71+
$entries["output_$env/rss/$slug.xml"][] = $this->fetchEntry($data, $authors);
72+
}
73+
}
74+
75+
$this->generateFeed($entries);
76+
}
77+
78+
/**
79+
* @param Author[] $entries
80+
*/
81+
protected function fetchEntry(Configuration $data, array $authors): Entry
82+
{
83+
$baseUrl = $this->configuration->get('url') ?? 'http://localhost';
84+
85+
return new Entry(
86+
$data->get('title'),
87+
$baseUrl . $data->get('url'),
88+
$authors,
89+
$data->get('blocks.content'),
90+
new \DateTimeImmutable($data->get('published_at')),
91+
);
92+
}
93+
94+
protected function slug(string $author): string
95+
{
96+
return mb_strtolower(preg_replace('/\W/', '_', $author));
97+
}
98+
99+
protected function generateFeed(array $entries = []): void
100+
{
101+
foreach ($entries as $filePath => $posts) {
102+
$rss = new SitemapGenerator();
103+
if ($title = $this->configuration->get('title')) {
104+
$rss->setTitle($title);
105+
}
106+
if ($subtitle = $this->configuration->get('subtitle')) {
107+
$rss->setDescription($subtitle);
108+
}
109+
110+
foreach ($posts as $post) {
111+
$rss->addEntry($post);
112+
}
113+
114+
$rss->saveFeed($filePath);
115+
}
116+
}
117+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace App\Bundles\AtomFeedGeneratorBundle\DependencyInjection;
4+
5+
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6+
use Symfony\Component\Config\Definition\ConfigurationInterface;
7+
8+
class Configuration implements ConfigurationInterface
9+
{
10+
public function getConfigTreeBuilder(): TreeBuilder
11+
{
12+
return new TreeBuilder('sculpin_atom_feed_generator');
13+
}
14+
}

0 commit comments

Comments
 (0)