Showing 2 changed files with 54 additions and 0 deletions
+6
sources/gennews.sh
... ...
@@ -24,6 +24,12 @@ do
24 24
   log "====== $gen"
25 25
   output=$(echo $gen|cut -d'-' -f2|cut -d'.' -f1).html
26 26
   php $gen > $output 2>> $LOGFILE
27
+  NEWSALL="all-$output"
28
+  NEWSPDF=$(basename $NEWSALL .html).pdf
29
+  log "Generating Single HTML for $NEWSALL"
30
+  php news2html.php $output > $NEWSALL 2>> $LOGFILE
31
+  log "Generating PDF $NEWSPDF"
32
+  xvfb-run -a --server-args="-screen 0, 800x600x16" /usr/bin/wkhtmltopdf -q -l -s A5 $NEWSALL $NEWSPDF 2>> $LOGFILE 
27 33
 done
28 34
 log "Done."
29 35
 log "=================================================================="
+48
sources/news2html.php
... ...
@@ -0,0 +1,48 @@
1
+<?php
2
+
3
+$source=null;
4
+if( isset($argc) ) {
5
+  $source=$argv[1];
6
+}
7
+else {
8
+  return 1;
9
+}
10
+
11
+
12
+include_once( 'news-constants.php' );
13
+$MAX_ITEMS=$NEWS_RSS_MAX_ITEMS;
14
+
15
+$article_content = file_get_contents($source);
16
+$article_content_utf8 = mb_convert_encoding($article_content, 'HTML-ENTITIES', "UTF-8");
17
+$doc = new DOMDocument();
18
+$doc->preserveWhiteSpace = false;
19
+$doc->formatOutput       = true;
20
+$libxml_previous_state = libxml_use_internal_errors(true);
21
+$doc->loadHTML($article_content_utf8);
22
+libxml_use_internal_errors($libxml_previous_state);
23
+
24
+$html = "<html>".PHP_EOL;
25
+$html .= "<head>".PHP_EOL;
26
+$html .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'.PHP_EOL;
27
+$html .= '<meta name="viewport" content="width=device-width, initial-scale=1.0">'.PHP_EOL;
28
+$html .= '<title>'.$source.'</title>';
29
+$html .= '<style>'.PHP_EOL;
30
+$html .= 'html { font-family: "Lucida Sans", sans-serif; }'.PHP_EOL;
31
+$html .= 'img { width: 80%; margin-left: auto; margin-right: auto; }'.PHP_EOL;
32
+$html .= '.img-conspiracy { width: 50%; margin-left: 30%; margin-right: auto; }'.PHP_EOL;
33
+$html .= 'iframe { width: 80%; margin-left: auto; margin-right: auto; }'.PHP_EOL;
34
+$html .= '.article-sep { width: 90%; border: 5px solid gray; margin-left: auto; margin-right: auto; margin-top: 100px; margin-bottom: 10px;}'.PHP_EOL;
35
+$html .= '.article-ext { max-width: 800px;}'.PHP_EOL;
36
+$html .= '</style>'.PHP_EOL;
37
+$html .= '</head>'.PHP_EOL;
38
+$html .= '<body>'.PHP_EOL;
39
+for($i=0; $i < $MAX_ITEMS; $i++ ) {
40
+  $html .= '<div class="article-ext">'.PHP_EOL;
41
+  $html .= DOMInnerHTML($doc->getElementById($i));
42
+  $html .= '<div class="article-sep"></div>'.PHP_EOL;
43
+  $html .= '</div>'.PHP_EOL;
44
+}
45
+$html .= '</body>'.PHP_EOL;
46
+$html .= '</html>'.PHP_EOL;
47
+echo $html;
48
+?>