diff --git a/.github/workflows/buildsite.yml b/.github/workflows/buildsite.yml new file mode 100644 index 0000000..80c559e --- /dev/null +++ b/.github/workflows/buildsite.yml @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..73cf2e8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +web/ diff --git a/bin/build b/bin/build new file mode 100755 index 0000000..52b6eae --- /dev/null +++ b/bin/build @@ -0,0 +1,79 @@ +#!/usr/bin/perl + +use v5.40; +use JSON; +use File::Copy; +use Template; +use Template::Provider::Pandoc; + +use PPC; + +my @ppcs; + +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 () { + 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 () { + s|^docs/||; + my $out = s|\.md|/index.html|r; + + $tt->process($_, {}, $out) + or die $tt->error; +} + +mkdir 'web/images'; +for () { + 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; + diff --git a/cpanfile b/cpanfile new file mode 100644 index 0000000..f210f57 --- /dev/null +++ b/cpanfile @@ -0,0 +1,4 @@ +requires 'File::Copy'; +requires 'JSON'; +requires 'Template'; +requires 'Template::Provider::Pandoc'; diff --git a/docs/process.md b/docs/process.md index 063641e..1e5286c 100644 --- a/docs/process.md +++ b/docs/process.md @@ -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? @@ -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 @@ -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. diff --git a/in/index.tt b/in/index.tt new file mode 100644 index 0000000..3b4c623 --- /dev/null +++ b/in/index.tt @@ -0,0 +1,37 @@ +

Proposed Perl Changes

+ +

Welcome to the Proposed Perl Changes web site.

+ +

Download this data as JSON.

+ + + + + + + + + + + +[% FOR ppc IN ppcs -%] + + + + + + + +[% END -%] + +
IDTitleStatusAuthor(s)Sponsor
[% ppc.id | html %][% ppc.title | html %][% ppc.status | html %][% ppc.author | html %][% ppc.sponsor | html %]
+ + diff --git a/in/style.css b/in/style.css new file mode 100644 index 0000000..ff5ebd0 --- /dev/null +++ b/in/style.css @@ -0,0 +1,3 @@ +main > .container { + padding: 60px 15px 0; +} diff --git a/lib/PPC.pm b/lib/PPC.pm new file mode 100644 index 0000000..9674551 --- /dev/null +++ b/lib/PPC.pm @@ -0,0 +1,79 @@ +use v5.40; +use experimental qw[class signatures]; + +class PPC; + +use Pandoc; + +field $author :param :reader = ''; +field $id :param :reader; +field $slug :param :reader; +field $sponsor :param :reader = ''; +field $status :param :reader; +field $title :param :reader; + +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>) { + !$ppc{title} and m|^#\s+(.*)| and $ppc{title} = md2text($_); + + $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} + } + + for (qw[author sponsor]) { + $ppc{$_} //= ''; + $ppc{$_} =~ s|\@.+?>|\@XXXX>|g; + } + + return $class->new(%ppc); +} + +sub md2text($md_string) { + return pandoc->convert( markdown => 'plain', $md_string); +} diff --git a/ppcs/ppc0030-undef-aware-equality.md b/ppcs/ppc0030-undef-aware-equality.md index 8c2f791..fa1b05c 100644 --- a/ppcs/ppc0030-undef-aware-equality.md +++ b/ppcs/ppc0030-undef-aware-equality.md @@ -109,7 +109,7 @@ match( $x : equ ) { * Should we also provide negated versions of these operators? While much rarer in practice, it may be useful to provide a "not equ", perhaps spelled `nequ` or `neu`; and likewise `!===` or `!==` for the numerical version. These do not suffer the sorting order problem outlined above for more general comparisons. -* As an entirely alternate proposal, should we instead find ways to apply behaviour-modifying flags to the existing operators? That is, rather than adding a new `equ` and `===` could we instead consider some syntax such as `eq:u` and `==:u` as a modifier flag, similar to the flags on regexp patterns, as a way to modify operators? This would be extensible in a more general way to more operators, while also allowing more flexible flags in future, such as for instance a case-ignoring string comparison to be spelled `eq:i`. This alternate proposal may be the subject of an alternate PPC document. +* As an entirely alternate proposal, should we instead find ways to apply behaviour-modifying flags to the existing operators? That is, rather than adding a new `equ` and `===` could we instead consider some syntax such as `eq:u` and `==:u` as a modifier flag, similar to the flags on regexp patterns, as a way to modify operators? This would be extensible in a more general way to more operators, while also allowing more flexible flags in future, such as for instance a case-ignoring string comparison to be spelled `eq:i`. This alternate proposal is be the subject of an [alternate PPC document](ppc0031-metaoperator-flags.md). * How to pronounce the name of this new operator? I suggest "ee-koo", avoiding the "you" part of the sound. diff --git a/ttlib/page.tt b/ttlib/page.tt new file mode 100644 index 0000000..01abf1f --- /dev/null +++ b/ttlib/page.tt @@ -0,0 +1,105 @@ + + + +[% IF base -%] + +[% END -%] + + + + + + Proposed Perl Changes + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+
+[% content %] +
+
+ + + + + +