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

Mowyw replacement #221

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
http://localhost:5500 {
root * /usr/share/caddy
file_server
}

13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM docker.io/rakudo-star:latest as builder

WORKDIR /usr/src/app

COPY . .
RUN zef install --deps-only .
RUN raku publish-sources.raku

FROM docker.io/caddy:latest
# Processed static files are written to ./online
COPY --from=builder /usr/src/app/online /usr/share/caddy
COPY Caddyfile /etc/caddy/Caddyfile

28 changes: 28 additions & 0 deletions META6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"auth": "zef:raku",
"authors": [
"The Raku website authors"
],
"build-depends": [
],
"depends": [
"HTTP::Tiny:ver<0.2.5>:auth<zef:jjatria>",
"JSON::Fast:ver<0.19>:auth<cpan:TIMOTIMO>",
"Path::Finder:ver<0.4.6>:auth<zef:leont>",
"Template6:ver<0.14.0>:auth<zef:raku-community-modules>"
],
"description": "The distribution for the tooling of the raku.org site.",
"license": "Artistic-2.0",
"name": "raku-website",
"perl": "6.d",
"provides": {
},
"resources": [
],
"source-url": "",
"tags": [
],
"test-depends": [
],
"version": "0.0.1"
}
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# raku.org
This is the source code for <https://raku.org>.

It is rendered with [mowyw](https://perlgeek.de/en/software/mowyw)
every 15 minutes, so updates to the repository should also result in
It is rendered every 15 minutes, so updates to the repository should also result in
an update of <https://raku.org>
If not, talk to [moritz] on
[#raku](https://kiwiirc.com/client/irc.libera.chat/#raku).

### Multilingual translation
[Chinese translation](https://github.com/ccworld1000/perl6.org).

### Guidelines
Here are some guidelines that you should respect when changing this site:

Expand Down Expand Up @@ -56,20 +52,23 @@ Here are some guidelines that you should respect when changing this site:
### Build
To run this site locally:

- Install the following modules:
- libxml2 is a native binary dependency; make sure to install it as your platform requires (except Windows where it's baked into the Raku dist)

- for content generation, install this repository as a module:
`zef install .`

- Install the following Perl modules for setting up the server:

`cpanm App::Mowyw Text::VimColor Plack IO::Socket::SSL HTML::Template::Compiled Mojolicious`
`cpanm Plack IO::Socket::SSL`

- Run the following commands to populate the `./online` folder and launch a local web server for testing:
```
mowyw
```sh
raku fetch-recent-blog-posts.raku
raku publish-sources.raku
plackup
```
- Open http://localhost:5000/index.html in your browser

Tip: if you remove `source/archive` directory, `mowyw` generation will run a
lot faster. Useful for checking frequently-made changes.

### LICENSE

See [LICENSE](LICENSE) file for the details of the license of the code in this repository.
Expand Down
36 changes: 0 additions & 36 deletions fetch-recent-blog-posts.pl

This file was deleted.

47 changes: 47 additions & 0 deletions fetch-recent-blog-posts.raku
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env raku

use LibXML::Reader:ver<0.10.4>:auth<zef:dwarring>:api<0.10.0>;
use HTTP::Tiny:ver<0.2.5>:auth<zef:jjatria>;
use JSON::Fast:ver<0.19>:auth<cpan:TIMOTIMO>;

my $tx = HTTP::Tiny.new.get("https://planet.raku.org/atom.xml");

unless $tx<success> {
warn "ERROR $tx<status> ($tx<reason>)";
exit;
}

my $xml-content = $tx<content>.decode;

my $globalReader = LibXML::Reader.new: string => $xml-content;

my $found-posts = 0;
my @posts-data = gather while $globalReader.nextElement('entry') && $found-posts < 7 {
my $entryString = $globalReader.readOuterXml;

my $entryReader = LibXML::Reader.new: string => $entryString;
# Look for text/html links and use the first without it if we don't find any
my $link-href;
while $entryReader.nextElement('link') {

next if $entryReader.getAttribute('rel') andthen $_ eq 'replies';
if $entryReader.getAttribute('type') andthen $_ eq 'text/html' {
$link-href = $entryReader.getAttribute('href');
last;
}
$_ = $entryReader.getAttribute('href') without $link-href;
}
# Hackish fix to get rid of comment entries from medium.com.
# Only articles appear to have `category` elements, so if we detect
# an entry from medium.com, ensure it also has `category` element
next if $link-href.starts-with('https://medium\.com') && !LibXML::Reader.new(string => $entryString).nextElement('category');

my $title = LibXML::Reader.new(string => $entryString).&{ .nextElement('title') && .readInnerXml };

$found-posts++;
take { :$title, link => $link-href }; # TODO these used to be "XML escaped" but what does that mean and is that even needed?

};

'online/recent-blog-posts.json'.IO.spurt: to-json @posts-data;
say 'Successfully wrote new blog posts';
File renamed without changes.
21 changes: 21 additions & 0 deletions includes/footer → includes/common-wrapper.tt
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
<!DOCTYPE html>

<!-- Hacking: see NOTES and TODO in this directory -->

<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>[% GET title %]</title>
[% IF extra_header_template %] [% INSERT extra_header_template %] [% END %]

<link href="/favicon.ico" rel="shortcut icon" type="image/x-icon">
<link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="/style.css?v=1" rel="stylesheet">
</head>
<body>
<div class="bg">
<div class="container">
[% content %]
</div>
</div>

Expand Down
23 changes: 0 additions & 23 deletions includes/header

This file was deleted.

39 changes: 0 additions & 39 deletions includes/menu-nav

This file was deleted.

27 changes: 27 additions & 0 deletions includes/menu-nav.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<nav class="navbar navbar-fixed-top navbar-inverse">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed"
data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li id="nav-home"[% IF current eq 'home' %] class="active"[% END %]><a href="/">Home</a></li>
<li id="nav-downloads"[% IF current eq 'downloads' %] class="active"[% END %]><a href="/downloads">Download</a></li>
<li id="nav-community"[% IF current eq 'community' %] class="active"[% END %]><a href="/community/">Community</a></li>
<li id="nav-docs"[% IF current eq 'docs' %] class="active"[% END %]><a href="https://docs.raku.org">Documentation</a></li>
<li id="nav-res"[% IF current eq 'res' %] class="active"[% END %]><a href="/resources/">Resources</a></li>
<li id="nav-modules"[% IF current eq 'modules' %] class="active"[% END %]><a href="https://modules.raku.org/">Modules</a></li>
<li id="nav-whatever"[% IF current eq 'whatever' %] class="active"[% END %]><a href="/whatever/">IDEs</a></li>
<li id="nav-fun" [% IF current eq 'fun' %] class="active"[% END %]><a href="/fun/">Fun</a></li>
<li id="nav-faq"[% IF current eq 'faq' %] class="active"[% END %]><a href="https://docs.raku.org/language/faq">FAQ</a></li>
</ul>
</div>
</div>
</nav>
3 changes: 3 additions & 0 deletions includes/more-header.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<meta name="description" content="Home page of the Raku Programming Language." />
<meta name="verify-v1" content="p7bEStVpDsW4ixm9YbF1ck02FRQfdA97ZL9mJnt0iQ0=" />
<meta name="google-site-verification" content="fDTmO9fcCRRgBqbKirQidKJ6nhTqnolHrKrgwVWJxZA" />
2 changes: 0 additions & 2 deletions mowyw.conf

This file was deleted.

52 changes: 52 additions & 0 deletions publish-sources.raku
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env raku
use v6.d;
use Path::Finder:ver<0.4.6>;
use Template6:ver<0.14.0>;


sub published-counterpart(IO::Path $source-path, Bool :$safe-path) {
my $same-under-online = 'online'.IO.add: $source-path.relative('source');
mkdir $same-under-online.parent if $safe-path;
$same-under-online.extension eq 'tt' ?? $same-under-online.extension('html') !! $same-under-online
}

sub is-freshly-modified($_, *%) {
.&published-counterpart.modified < .modified
}

sub MAIN(Bool :$incremental) {

my $non-templates = Path::Finder.file.ext(none('tt'));
$non-templates.=and(&is-freshly-modified) if $incremental;

for $non-templates.in('source', :!loop-safe, :!sorted).race {
print "Copying '$_'..." if %*ENV<VERBOSE>;
.copy: .&published-counterpart(:safe-path);
say 'Done.' if %*ENV<VERBOSE>;
}

my $wrapper-engine = Template6.new: wrappers => ['common-wrapper'], :reset;
$wrapper-engine.add-path: 'includes';

my $wrapped-templates = Path::Finder.skip-dir('snippets').file.ext('tt');
$wrapped-templates.=and(&is-freshly-modified) if $incremental;

for $wrapped-templates.in('source', :!loop-safe, :!sorted).race {
print "Processing '$_'..." if %*ENV<VERBOSE>;
.&published-counterpart(:safe-path).spurt: $wrapper-engine.process($_);
say 'Done.' if %*ENV<VERBOSE>;
}

my $raw-engine = Template6.new: :reset;
$raw-engine.add-path: 'includes';

my $raw-templates = Path::Finder.ext('tt');
$raw-templates.=and(&is-freshly-modified) if $incremental;

for $raw-templates.in('source/snippets', :!loop-safe, :!sorted).race {
print "Processing '$_'..." if %*ENV<VERBOSE>;
.&published-counterpart(:safe-path).spurt: $raw-engine.process($_);
say 'Done.' if %*ENV<VERBOSE>;
}

}
2 changes: 0 additions & 2 deletions source/TEMP-example.html

This file was deleted.

2 changes: 2 additions & 0 deletions source/TEMP-example.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[% SET title = 'Raku examples -- just a temporary hack' %]
<!--#include virtual="/snippet"-->
6 changes: 3 additions & 3 deletions source/about/index.html → source/about/index.tt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[% setvar title About raku.org %]
[% SET title = 'About raku.org' %]

[% menu nav about %]
[% PROCESS 'menu-nav' current = 'about' %]

<header id="subpage-header" class="lead well">
[% include camelia %]
[% INSERT 'camelia' %]
<h2>About raku.org</h2>
<p>raku.org is, just like Raku, a volunteer driven project.
Content on raku.org should be up-to-date rather than comprehensive.
Expand Down
6 changes: 3 additions & 3 deletions source/community/index.html → source/community/index.tt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[% setvar title Raku Community %]
[% SET title = 'Raku Community' %]

[% menu nav community %]
[% PROCESS 'menu-nav' current = 'community' %]

<header id="subpage-header" class="lead well">
[% include camelia %]
[% INSERT 'camelia' %]

<h2>The <b>Raku</b> Community welcomes you</h2>
<p>
Expand Down
Loading