-
Notifications
You must be signed in to change notification settings - Fork 25
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
+368
−4
Closed
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 07936cb
Copy the CSS into place
davorg f68f457
Add JSON download
davorg 98d7b93
Forgot something :-/
davorg 74b9053
Obfuscate email addresses in main table
davorg 0c38d1c
Add footer text
davorg 3bdce96
Same obfuscation for sponsors
davorg 4a170ee
Make some links relative (so <base> hack works)
davorg 44f77aa
Support the use of a <base> element
davorg 23322cf
Reorder columns
davorg 91f5103
Fix local css link
davorg 307795f
Link to related PPC
matthewpersico 24edcc7
Fix JSON link (and anchor text)
davorg 0fb48d4
Add basic datatable support
davorg 83bcd78
Fix a couple of typos
davorg 3e0ee4e
Fix incorrect page metadata
davorg bb49549
The title is Markdown - fix that
davorg bd65c9d
Add a simple website
davorg a72078c
Copy the CSS into place
davorg 1a66ea8
Add JSON download
davorg c90f466
Forgot something :-/
davorg 52a3d3b
Obfuscate email addresses in main table
davorg 12ab7fb
Add footer text
davorg 76438a4
Same obfuscation for sponsors
davorg f4638cd
Make some links relative (so <base> hack works)
davorg c118eef
Support the use of a <base> element
davorg efaaf47
Reorder columns
davorg 7b9fed8
Fix local css link
davorg 1d4c437
Fix JSON link (and anchor text)
davorg 10d29a0
Add basic datatable support
davorg fbdd4e2
Fix a couple of typos
davorg 88a6908
Fix incorrect page metadata
davorg 741cb1a
The title is Markdown - fix that
davorg 6547fd1
Merge branch 'main' of github.com:davorg/PPCs
davorg 9dd4885
Remove unused variable
davorg f833d79
Don't need strict or warnings with use 5.38
davorg 9f812ea
Require v5.38 in class too
davorg a5f0fbc
Fix "uninitialised" warning
davorg 48f1228
Update to using Perl 5.40
davorg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
main > .container { | ||
padding: 60px 15px 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
use experimental qw[builtin class signatures]; | ||
|
||
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; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 hasmodule_true
so you can drop the1;
from the end of this file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. Thanks. Done.
There was a problem hiding this comment.
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 :-/
There was a problem hiding this comment.
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:
Builtin has version bundles too now which are automatically imported by the corresponding use version line so we can drop this line completely:
And the biggest win is we can apply
:reader
to our fields and drop our handed rolled readers:Remove:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, just laziness. The system I was working on had 5.38 installed :-)
But, yeah, I should update that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done