File: moarvm.org_releases.pl

package info (click to toggle)
moarvm 2020.12%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 18,652 kB
  • sloc: ansic: 268,178; perl: 8,186; python: 1,316; makefile: 768; sh: 287
file content (145 lines) | stat: -rwxr-xr-x 4,806 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use feature qw(unicode_strings say);
use English '-no_match_vars';
binmode STDOUT, ':encoding(UTF-8)';
binmode STDERR, ':encoding(UTF-8)';
use Text::Markdown 'markdown';

sub slurp {
  my ($filename) = @_;
  local $INPUT_RECORD_SEPARATOR = undef;
  open my $fh, '<', $filename;
  binmode $fh, ':encoding(UTF-8)';
  return <$fh>;
}
sub main {
    my $ChangeLog = slurp 'docs/ChangeLog';
    $ChangeLog =~ s/(^\s*[^+].*?:\n[ ]*)([+])/$1\n$2/xmsg;
    say beginning_text() . process_changelog(html_escape($ChangeLog)) . end_text();
}
main();
sub process_changelog {
    my ($in) = @_;
    my @release_html;
    # Extracts the text from the 'New in XXXX.XX' to the next 'New in XXXX.XX'
    # if there are no 'New in' left it extracts to the end of the document.
    while ($in =~ s/(New in ([\d.]+)(.*?))(New in [\d.]+|$)/$4/s) {
        my $sec = $3;
        my $release = $2;
        print STDERR "$release\n";
        my $md_obj    = Text::Markdown->new;
        my $mid = $md_obj->markdown($sec);
my $start = <<"END";
<div class="panel panel-default">
        <div class="panel-heading">
          <h3 class="panel-title">$release</h3>
        </div>
        <div class="panel-body">
END
        my $end = <<"END";
<p><a href="releases/MoarVM-{$release}.tar.gz" class="btn btn-primary" role="button">Download</a></p>
</div>
</div>
END
        my $html = start_enclosing_text($release) . $mid . end_enclosing_text($release);
        push @release_html, $html;
    }
    return join '', @release_html;
}
# Escapes &, < and > for html
sub html_escape {
  my ($text) = @_;
  $text =~ s/[&]/&amp;/g;
  $text =~ s/[<]/&lt;/g;
  $text =~ s/[>]/&gt;/g;
  return $text;
}
# The text comes before every version
sub start_enclosing_text {
  my ($release) = @_;
  my $start = <<"END";
<div class="panel panel-default">
        <div class="panel-heading">
          <h3 class="panel-title">$release</h3>
        </div>
        <div class="panel-body">
END
  return $start;
}
# This text comes after every version
sub end_enclosing_text {
  my ($release) = @_;
  my $end = <<"END";
<p><a href="releases/MoarVM-$release.tar.gz" class="btn btn-primary" role="button">Download</a></p>
</div>
</div>
END
  return $end;
}
# This text begins the html document (only used once).
sub beginning_text {
  <<'END';
<!DOCTYPE html>
<html lang="en-US">
  <head>
    <title>MoarVM - A VM for NQP and Rakudo Perl 6</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/local.css" rel="stylesheet">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
    <div class="container">

      <a href="https://github.com/MoarVM/MoarVM"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>

      <div class="page-header" id="banner">
        <h1>MoarVM</h1>
        <p class="lead">A VM for NQP And Rakudo Perl 6</p>
      </div>
      <nav class="navbar navbar-default" role="navigation">
        <ul class="nav navbar-nav">
          <li><a href="index.html">Home</a></li>
          <li><a href="features.html">Features</a></li>
          <li><a href="roadmap.html">Roadmap</a></li>
          <li class="active"><a href="releases.html">Releases</a></li>
          <li><a href="contributing.html">Contributing</a></li>
        </ul>
      </nav>
END
}
# This text ends the html document (only used once).
sub end_text {
<<'END';

      <footer>
        <div class="row">
          <div class="col-lg-12">
              <p>Site maintained by the MoarVM team.</p>
              <p>Based on <a href="http://getbootstrap.com" rel="nofollow">Bootstrap</a>,
              with theme from <a href="http://bootswatch.com/">Bootswatch</a>. Icons from
              <a href="http://fortawesome.github.io/Font-Awesome/" rel="nofollow">Font Awesome</a>.
              Web fonts from <a href="http://www.google.com/webfonts" rel="nofollow">Google</a>.
          </div>
        </div>
      </footer>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://code.jquery.com/jquery.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>
END
}