Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a simple website #67

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
68a8faf
Add a simple website
davorg Jan 13, 2025
07936cb
Copy the CSS into place
davorg Jan 13, 2025
f68f457
Add JSON download
davorg Jan 13, 2025
98d7b93
Forgot something :-/
davorg Jan 13, 2025
74b9053
Obfuscate email addresses in main table
davorg Jan 14, 2025
0c38d1c
Add footer text
davorg Jan 14, 2025
3bdce96
Same obfuscation for sponsors
davorg Jan 14, 2025
4a170ee
Make some links relative (so <base> hack works)
davorg Jan 18, 2025
44f77aa
Support the use of a <base> element
davorg Jan 18, 2025
23322cf
Reorder columns
davorg Jan 18, 2025
91f5103
Fix local css link
davorg Jan 18, 2025
307795f
Link to related PPC
matthewpersico Jan 11, 2025
24edcc7
Fix JSON link (and anchor text)
davorg Jan 24, 2025
0fb48d4
Add basic datatable support
davorg Jan 24, 2025
83bcd78
Fix a couple of typos
davorg Jan 24, 2025
3e0ee4e
Fix incorrect page metadata
davorg Jan 26, 2025
bb49549
The title is Markdown - fix that
davorg Jan 26, 2025
bd65c9d
Add a simple website
davorg Jan 13, 2025
a72078c
Copy the CSS into place
davorg Jan 13, 2025
1a66ea8
Add JSON download
davorg Jan 13, 2025
c90f466
Forgot something :-/
davorg Jan 13, 2025
52a3d3b
Obfuscate email addresses in main table
davorg Jan 14, 2025
12ab7fb
Add footer text
davorg Jan 14, 2025
76438a4
Same obfuscation for sponsors
davorg Jan 14, 2025
f4638cd
Make some links relative (so <base> hack works)
davorg Jan 18, 2025
c118eef
Support the use of a <base> element
davorg Jan 18, 2025
efaaf47
Reorder columns
davorg Jan 18, 2025
7b9fed8
Fix local css link
davorg Jan 18, 2025
1d4c437
Fix JSON link (and anchor text)
davorg Jan 24, 2025
10d29a0
Add basic datatable support
davorg Jan 24, 2025
fbdd4e2
Fix a couple of typos
davorg Jan 24, 2025
88a6908
Fix incorrect page metadata
davorg Jan 26, 2025
741cb1a
The title is Markdown - fix that
davorg Jan 26, 2025
6547fd1
Merge branch 'main' of github.com:davorg/PPCs
davorg Jan 26, 2025
9dd4885
Remove unused variable
davorg Feb 2, 2025
f833d79
Don't need strict or warnings with use 5.38
davorg Feb 2, 2025
9f812ea
Require v5.38 in class too
davorg Feb 4, 2025
a5f0fbc
Fix "uninitialised" warning
davorg Feb 4, 2025
48f1228
Update to using Perl 5.40
davorg Feb 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/buildsite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Generate web page

on:
push:
branches: 'main'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
container: perl:latest

steps:
- name: Perl version
run: perl -v

- name: Checkout
uses: actions/checkout@v4

- name: Install pandoc and cpanm
run: apt-get update && apt-get install -y pandoc cpanminus

- name: Install modules
run: |
cpanm --installdeps --notest .

- name: Get repo name into environment
run: |
echo "REPO_NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}" >> $GITHUB_ENV

- name: Create pages
env:
PERL5LIB: lib
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p web
perl bin/build $REPO_NAME

- name: Update pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: web/

deploy:
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web/
83 changes: 83 additions & 0 deletions bin/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/perl

use strict;
use warnings;

use v5.38;
use File::Copy;
use JSON;
use Template;
use Template::Provider::Pandoc;

use PPC;

my @ppcs;
my %status;

my $outpath = './web';
my $template_path = [ './ppcs', './docs', './in', './ttlib' ];

my $base = shift || $outpath;
$base =~ s/^\.//;
$base = "/$base" if $base !~ m|^/|;
$base = "$base/" if $base !~ m|/$|;

my $provider = Template::Provider::Pandoc->new({
INCLUDE_PATH => $template_path,
});

my $tt = Template->new({
LOAD_TEMPLATES => [ $provider ],
INCLUDE_PATH => $template_path,
OUTPUT_PATH => $outpath,
RELATIVE => 1,
WRAPPER => 'page.tt',
VARIABLES => {
base => $base,
}
});

for (<ppcs/*.md>) {
my $ppc = PPC->new_from_file($_);
push @ppcs, $ppc;

$tt->process($ppc->in_path, {}, $ppc->out_path)
or warn $tt->error;
}

my $vars = {
ppcs => \@ppcs,
};

$tt->process('index.tt', $vars, 'index.html')
or die $tt->error;

for (<docs/*.md>) {
s|^docs/||;
my $out = s|\.md|/index.html|r;

$tt->process($_, {}, $out)
or die $tt->error;
}

mkdir 'web/images';
for (<images/*>) {
copy $_, "web/$_";
}

if (-f 'in/style.css') {
copy 'in/style.css', 'web/style.css';
}

if (-f 'CNAME') {
copy 'CNAME', "web/CNAME";
}

my $json = JSON->new->pretty->canonical->encode([
map { $_->as_data } @ppcs
]);

open my $json_fh, '>', 'web/ppcs.json' or die $!;

print $json_fh $json;

4 changes: 4 additions & 0 deletions cpanfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
requires 'File::Copy';
requires 'JSON';
requires 'Template';
requires 'Template::Provider::Pandoc';
6 changes: 3 additions & 3 deletions docs/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Hence we need a process that
We'd like to record proposals to improve the language and their status as "Request For Comment" documents in their own repository under the Perl organisation on GitHub.


We have a [template](template.md) for what an completed implemented PPC should end up as, but if all you have is an idea - don't worry, we'll help you get there. We're still figuring this process out, so for now we're doing it as mail messages sent to p5p, not as "pull requests" to the PPC repository (or "issues" on the source repository). This way we can see if the process works as hoped, and fix the parts that don't.
We have a [template](./template.md) for what an completed implemented PPC should end up as, but if all you have is an idea - don't worry, we'll help you get there. We're still figuring this process out, so for now we're doing it as mail messages sent to p5p, not as "pull requests" to the PPC repository (or "issues" on the source repository). This way we can see if the process works as hoped, and fix the parts that don't.


## What makes a good idea?
Expand All @@ -46,7 +46,7 @@ Not every good idea belongs in the Perl core. Some are better implemented on CPA

## The Process

![a flowchart of the process described below](/images/flowchart.png)
![a flowchart of the process described below](./images/flowchart.png)


### Pre-PPC
Expand All @@ -63,7 +63,7 @@ During this phase, you (the proposer) are responsible for moving things forward.

### Draft Proposal

The PSC has agreed that you should write a formal draft proposal. You get the [template document](template.md) and fill it out. You take its advice, thinking hard about what goes in each section. Then you post it to p5p as an email with the subject "PROPOSAL: my great idea". Members of the list will reply with more questions and suggested amendments. You should read them and amend the proposal to clarify your ideas or react to valid criticism.
The PSC has agreed that you should write a formal draft proposal. You get the [template document](./template.md) and fill it out. You take its advice, thinking hard about what goes in each section. Then you post it to p5p as an email with the subject "PROPOSAL: my great idea". Members of the list will reply with more questions and suggested amendments. You should read them and amend the proposal to clarify your ideas or react to valid criticism.

During this phase, you (the proposer) are responsible for moving things
forward.
Expand Down
37 changes: 37 additions & 0 deletions in/index.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<h1>Proposed Perl Changes</h1>

<p>Welcome to the Proposed Perl Changes web site.</p>

<p>Download this data as <a href="./ppcs.json">JSON</a>.</p>
<table class="table" id="datatable">
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>Status</th>
<th>Author(s)</th>
<th>Sponsor</th>
</tr>
</thead>
<tbody>
[% FOR ppc IN ppcs -%]
<tr>
<td>[% ppc.id | html %]</td>
<td><a href="./[% ppc.slug %]/">[% ppc.title | html %]</a></td>
<td>[% ppc.status | html %]</td>
<td>[% ppc.author | html %]</td>
<td>[% ppc.sponsor | html %]</td>
</tr>
[% END -%]
</tbody>
</table>

<script>
window.dt = new window.simpleDatatables.DataTable("#datatable", {
perPageSelect: [5, 10, 15, ["All", -1]],
columns: [{
select: 0,
type: "numeric"
}]
});
</script>
3 changes: 3 additions & 0 deletions in/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
main > .container {
padding: 60px 15px 0;
}
80 changes: 80 additions & 0 deletions lib/PPC.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
use experimental qw[builtin class signatures];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a use v5.38 at the top, like the build script, I don't think anything in this file currently turns on strictures/warnings. As a benefit the the 5.38 bundle has module_true so you can drop the 1; from the end of this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. Thanks. Done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also fixed the warning that this revealed :-/

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, while we're here is there any reason not to use the latest Perl, 5.40? Looks like the GH Action uses "latest".

Using 5.40 would present a few opportunities to remove boilerplate:

Builtin is not longer experimental, so we can just do:

use experimental qw[class signatures];

Builtin has version bundles too now which are automatically imported by the corresponding use version line so we can drop this line completely:

use builtin 'trim';

And the biggest win is we can apply :reader to our fields and drop our handed rolled readers:

field $author  :param :reader = '';
field $id      :param :reader;
field $slug    :param :reader;
field $sponsor :param :reader = '';
field $status  :param :reader;
field $title   :param :reader;

Remove:

method author  { return $author }
method id      { return $id }
method slug    { return $slug }
method sponsor { return $sponsor }
method status  { return $status }
method title  { return $title }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any reason not to use the latest Perl, 5.40?

Honestly, just laziness. The system I was working on had 5.38 installed :-)

But, yeah, I should update that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


class PPC;

use builtin 'trim';

field $author :param = '';
field $id :param;
field $slug :param;
field $sponsor :param = '';
field $status :param;
field $title :param;

method author { return $author }
method id { return $id }
method slug { return $slug }
method sponsor { return $sponsor }
method status { return $status }
method title { return $title }

method in_path {
return "$slug.md";
}

method out_path {
return "$slug/index.html";
}

method as_data {
return {
id => $id,
status => $status,
author => $author,
sponsor => $sponsor,
slug => $slug,
title => $title,
};
}

# Very hacky parser

sub new_from_file($class, $ppc_file) {

open my $ppc_fh, '<', $ppc_file
or warn "Cannot open PPC [$_]: $!\n" and return;

my (%ppc, $is_preamble);

$ppc{slug} = $ppc_file;
$ppc{slug} =~ s|^ppcs/||;
$ppc{slug} =~ s|\.md$||;

while (<$ppc_fh>) {
$. == 1 and m|#\s+(.*)| and $ppc{title} = $1;

$is_preamble and /## abstract/i and last;

$_ = trim($_);

if ($is_preamble and $_) {

my ($key, $value) = split(/\s*:\s*/, $_, 2);

$ppc{lc $key} = $value;
}

# 'pre.+mble' because Paul likes to use 'Preämble'
/## pre.+mble/i and $is_preamble = 1;
}

if (exists $ppc{authors}) {
$ppc{author} = delete $ppc{authors}
}

$ppc{$_} =~ s|\@.+?>|\@XXXX>|g for (qw[author sponsor]);

return $class->new(%ppc);
}

1;
Loading