Add shortcodes to improve integration between distromatic static pages and wordpress

This commit is contained in:
Silvan Calarco 2020-06-25 20:14:06 +02:00
parent f94159a495
commit 8ab60cce44
13 changed files with 338 additions and 15 deletions

View File

@ -0,0 +1,34 @@
#!/bin/bash
echo $header
ext=${file/*.}
range=10000
filename="/var/www/www.openmamba.org/$file"
filename_check=`readlink -f $filename`
[ "${filename_check:0:27}" = "/mnt/sdc1/ftp/pub/openmamba" ] || exit 0
filelines=`wc -l $filename | awk '{ print $1 }'`
filepages=`expr $filelines / $range + 1`
if [ "$page" ]; then
[ $page -gt 0 ] || page=1
else
page=1
fi
from=`expr \( $page - 1 \) \* $range + 1`
to=`expr $from \+ $range - 1`
nextpage=`expr $page + 1`
prevpage=`expr $page - 1`
[ $from -ge $range ] && echo -n "<a href=\"showfile.html?file=$file&page=$prevpage\">&lt;</a>&nbsp;" || echo -n "&lt;&nbsp;"
idxsize=20
[ $page -gt $idxsize ] && idxfrom=`expr $page - $idxsize` || idxfrom=1
idxto=`expr $idxfrom + $idxsize \* 2`
[ $idxto -le $filepages ] || idxto=$filepages
[ $filepages -gt $idxsize ] && idxst=`expr $page - $idxsize` || idxst=1
for i in `seq $idxfrom $idxto`; do
if [ $i -eq $page ]; then
echo -n "$i&nbsp;"
else
echo -n "<a href=\"showfile.html?file=$file&page=$i\">$i</a>&nbsp;"
fi
done
[ $to -lt $filelines ] && echo -n "<a href=\"showfile.html?file=$file&page=$nextpage\">&gt;</a>&nbsp;" || echo -n "&gt;&nbsp;"
echo
exit 0

24
cgi-bin/text-to-html-filter.cgi Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
echo $header
ext=${file/*.}
range=10000
filename="/var/www/www.openmamba.org/$file"
filename_check=`readlink -f $filename`
[ "${filename_check:0:27}" = "/mnt/sdc1/ftp/pub/openmamba" ] || exit 0
if [ "$page" ]; then
[ $page -gt 0 ] || page=1
else
page=1
fi
from=`expr \( $page - 1 \) \* $range + 1`
to=`expr $from \+ $range - 1`
if [ "$ext" = "log" -o "$ext" = "spec" -o "$ext" = "patch" -o "$ext" = "diff" ]; then
/bin/sed -n "${from},${to}p" $filename | /bin/sed -e 's|\&|\&amp;|g' \
-e 's|<|\&lt;|g' \
-e 's|>|\&gt;|g' \
-e 's|\([[:alpha:][:digit:]]*\)\@[[:alpha:][:digit:]]*\.[[:alpha:][:digit:]\.]*|\1@...|g'
#'s|\&|\\&amp;|g' -e 's|<|\&lt;|g' -e 's|>|\&gt;|g' -e 's|\([[:alpha:][:digit:]]*\)\@[[:alpha:][:digit:]]*\.[[:alpha:][:digit:]\.]*|\1@...|g' /var/www/www.openmamba.org/$file
else
/bin/sed -n "${from},${to}p" $filename
fi
exit 0

View File

@ -62,7 +62,6 @@
<!--#set var="title" value="Index of all available repositories" --> <!--#set var="title" value="Index of all available repositories" -->
<!--#set var="description" value="Index of all available repositories" --> <!--#set var="description" value="Index of all available repositories" -->
<!--#endif --> <!--#endif -->
<!--#include virtual="/noheader.html" -->
<!-- cross domain --> <!-- cross domain -->
<table width="100%"><tr><td> <table width="100%"><tr><td>
<br> <br>

View File

@ -0,0 +1,4 @@
<!--#if expr="$QUERY_STRING = /lang=([a-zA-Z0-9\-+_\.]+)/" --><!--#set var="lang" value="$1" --><!--#endif -->
<!--#if expr=$lang --><!--#else --><!--#if expr="$HTTP_ACCEPT_LANGUAGE = /([a-zA-Z0-9]+)/" --><!--#set var="lang" value="$1" --><!--#endif --><!--#endif -->
<!--#if expr="${lang} != it" --><!--#set var="lang" value="en" --><!--#endif -->
<!--#include virtual="distromatic.naked.${lang}.html" -->

View File

@ -62,9 +62,7 @@
<!--#set var="title" value="Indice dei repository disponibili" --> <!--#set var="title" value="Indice dei repository disponibili" -->
<!--#set var="description" value="Indice dei repository disponibili" --> <!--#set var="description" value="Indice dei repository disponibili" -->
<!--#endif --> <!--#endif -->
<!--#include virtual="/distribution/noheader.html" -->
<table width="100%"><tr><td> <table width="100%"><tr><td>
<br>
<!--#if expr="$tag != ''" --> <!--#if expr="$tag != ''" -->
[<a href="?">repository</a>] [<a href="?">repository</a>]
<b><!--#echo var=tag --></b>: <b><!--#echo var=tag --></b>:
@ -81,11 +79,7 @@
<!--#endif --> <!--#endif -->
<br> <br>
<br> <br>
<table border=0><tr>
<td valign=top width="99%">
<!--#include virtual=${includefile} --> <!--#include virtual=${includefile} -->
</td></tr></table>
<br><font size=-1>
<!--#if expr="$tag != ''" --> <!--#if expr="$tag != ''" -->
[<a href="?">repository</a>] [<a href="?">repository</a>]
<!--#if expr="$group != _index" --> <!--#if expr="$group != _index" -->
@ -100,6 +94,3 @@
<!--#endif --> <!--#endif -->
[<a href="?tag=<!--#echo var=tag -->&amp;changelog">modifiche</a>] [<a href="?tag=<!--#echo var=tag -->&amp;changelog">modifiche</a>]
<!--#endif --> <!--#endif -->
</font>
</td>
</tr></table>

View File

@ -1 +1,80 @@
<META HTTP-EQUIV="Refresh" CONTENT="1; URL=http://openmamba.org/en/download"> <!--#if expr="$QUERY_STRING = /file=\([^\&]*\)/" --><!--#set var="file" value="$1" --><!--#endif -->
<!--#if expr="$file = /.*\/([a-zA-Z0-9\-+_\.]+)/" --><!--#set var="filename" value="$1" --><!--#endif -->
<!--#if expr="$file = /http:\/\/([a-zA-Z0-9\-+_\.]+)\/.*/" --><!--#set var="site" value="$1" --><!--#endif -->
<!--#if expr="$site" --><!--#else --><!--#set var="site" value="www.openmamba.org" --><!--#endif -->
<!--#set var="title" value="Download of $filename" -->
<!--#set var="description" value="openmamba download page" -->
<!--#set var="keywords" value="download,get" -->
<!--#if expr="$site = /www\.openmamba\.org/" -->
<!--#if expr="$filename" -->
<!-- # set var="bodyadd" value="onload=startDownload('$file');" -->
<!--#endif -->
<!--#endif -->
<!--#include virtual="/header.html" -->
<script language="javascript">
function startDownload(filename) {
location.href=filename;
//location.href="/download.php?file=" + filename;
}
</script>
<table width="100%"><tr><td>
<tr><td valign="middle">
<!--#if expr="$site = /www\.openmamba\.org/" -->
<!--#if expr="$filename" -->
<table align="center"><tr>
<td><img src="/images/download.png" alt="download"></td>
<td class="toptitle" style="text-transform: none;"><!--#echo var="filename" --></td>
</tr></table>
</td></tr>
<tr><td>
<table class="info"><tr><td>
<p><b>Thank you for your interest in <b>open<font color="green">mamba</font></b>.</b>
<p>openmamba is a "free as in speech" operating system but letting you use the web site and download it is a cost for us.
If you like this project you can help to keep it alive and make it better with your contribution by making a <a href="/donation.html">donation</a>.
<!--ul>
<li>by making a <a href="/donation.html">donation</a>
<li>by buying your computer and hardware at the <a href="http://www.mambastore.it">mambaSoft Store</a>
</ul-->
<div align=center>
<table style="border:0"><tr><td>
<div class="banner">
<table height="90"><tr><td>
<a href="/donation.html">Support<br>this project<br><br></a>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="10620735">
<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="Donate to the openmamba project">
<img alt="" border="0" src="https://www.paypal.com/it_IT/i/scr/pixel.gif" width="1" height="1"></form>
</td></tr></table></div>
</td><!--td>
<div class="banner">
<table height="90"><tr><td>
<a href="http://www.mambastore.it"><img src="/images/mambasoft-Store-300x41.png" width=300 height=41></a>
</td></tr></table></div>
</td><td>
<div class=banner>
<table height="90"><tr><td>
<b>COMPUTER WITH OPENMAMBA PREINSTALLED? MAMBASOFT RECOMMENDS:</b><br>
<!-- #set var="SHOW_BANNERS" value="2" -- >
<!-- #set var="HORIZONTAL_BANNERS" value="1" -- >
<!-- #include virtual="/cgi-bin/randombanner.cgi" -- >
</td></tr></table></div>
</td-->
</tr></table>
</td></tr></table>
</div>
<h2>Download in progress...</h2>
<p>Download for <b><!--#echo var="filename" --></b> will automatically start in a few seconds.
If it doesn't start, please click <a href="<!--#echo var="file"-->">here</a>.
<p>This file is downloaded from <b><!--#echo var="site"--></b></p>
<p><b>Not registered yet? <a href="/registration.html">Please register</a></b> to get
the best from openmamba services and to be informed on the latest news.
<!--#else -->
Sorry, there was an error with the request: invalid file.
<!--#else -->
Sorry, there was an error with the request: invalid file.
<!--#endif -->
<br><br>
</td></tr></table>
<!--#include virtual="/footer.html" -->

View File

@ -1 +1,82 @@
<META HTTP-EQUIV="Refresh" CONTENT="1; URL=http://openmamba.org/it/scarica"> <META HTTP-EQUIV="Refresh" CONTENT="1; URL=http://openmamba.org/it/scarica">
<!--#if expr="$QUERY_STRING = /file=\([^\&]*\)/" --><!--#set var="file" value="$1" --><!--#endif -->
<!--#if expr="$file = /.*\/([a-zA-Z0-9\-+_\.]+)/" --><!--#set var="filename" value="$1" --><!--#endif -->
<!--#if expr="$file = /http:\/\/([a-zA-Z0-9\-+_\.]+)\/.*/" --><!--#set var="site" value="$1" --><!--#endif -->
<!--#if expr="$site" --><!--#else --><!--#set var="site" value="www.openmamba.org" --><!--#endif -->
<!--#set var="title" value="Download di $filename" -->
<!--#set var="description" value="Pagina degli scaricamenti di openmamba" -->
<!--#set var="keywords" value="download,scarica" -->
<!--#if expr="$site = /www\.openmamba\.org/" -->
<!--#if expr="$filename" -->
<!--#set var="bodyadd" value="onload=startDownload('$file');" -->
<!--#endif -->
<!--#endif -->
<script language="javascript">
alert(filename);
function startDownload(filename) {
location.href=filename;
}
</script>
<table width="100%"><tr><td>
<tr><td valign="middle">
<!--#if expr="$site = /openmamba\.org/" -->
<!--#if expr="$filename" -->
<table align="center"><tr>
<td><img src="/images/download.png" alt="download"></td>
<td class="toptitle" style="text-transform: none;"><!--#echo var="filename" --></td>
</tr></table>
</td></tr>
<tr><td>
<table class=info><tr><td>
<p><b>Grazie per il tuo interessamento al progetto <b>open<font color="green">mamba</font></b>.</b>
<p>openmamba è un sistema libero e gratuito ma per darti la possibilità di usufruire dei servizi di questo sito e del download
mambaSoft deve sostenere delle spese non trascurabili. Se openmamba ti piace puoi aiutare a fare in modo
che continui ad esistere e migliorare attraverso il tuo contributo effettuando una <a href="/donation.html">donazione</a>.
<!--ul>
<li>effettuando una <a href="/donation.html">donazione</a>
<li>effettuando i tuoi acquisti di computer e materiale informatico presso il <a href="http://www.mambastore.it">mambaSoft Store</a>
</ul-->
<div align=center>
<table style="border:0"><tr><td>
<div class="banner">
<table height="90"><tr><td>
<a href="/donation.html">Supporta<br>openmamba<br><br></a>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="10620516">
<input type="image" src="https://www.paypal.com/it_IT/IT/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="Donazione per il progetto openmamba">
<img alt="" border="0" src="https://www.paypal.com/it_IT/i/scr/pixel.gif" width="1" height="1"></form>
</td></tr></table></div>
</td><!--td>
<div class="banner">
<table height="90"><tr><td>
<a href="http://www.mambastore.it"><img src="/images/mambasoft-Store-300x41.png" width=300 height=41></a>
</td></tr></table></div>
</td><td>
<div class=banner style="float:left">
<table height="90"><tr align=center><td align=center>
<b>PRODOTTI COMPATIBILI CON OPENMAMBA? MAMBASOFT TI CONSIGLIA:</b><br>
<!-- #set var="SHOW_BANNERS" value="2" -- >
<!-- #set var="HORIZONTAL_BANNERS" value="1" -- >
<!-- #include virtual="/cgi-bin/randombanner.cgi" -- >
</td></tr></table></div>
</td-->
</tr></table>
</td></tr></table>
</div>
<h2>Scaricamento in corso...</h2>
<p>Il download del file <b><!--#echo var="filename" --></b> partirà automaticamente entro pochi secondi. Se non dovesse
partire fai click <a href="<!--#echo var="file"-->" download>qui</a>.
<p>Il file viene scaricato dal sito <b><!--#echo var="site"--></b></p>
<p><b>Non ti sei ancora registrato? <a href="/registration.html">Registrati</a></b> per utilizzare al meglio i servizi di
openmamba ed essere sempre informato sulle ultime novità.
<!--#else -->
Sorry, there was an error with the request: invalid file.
<!--#else -->
Sorry, there was an error with the request: invalid file given.
<!--#endif -->
<br><br>
</td></tr></table></div>
<!--#include virtual="/footer.html" -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -0,0 +1,18 @@
<!--#if expr="$QUERY_STRING = /file=\([^\&]*\)/" --><!--#set var="file" value="$1" --><!--#endif -->
<!--#if expr="$QUERY_STRING = /page=\([^\&]*\)/" --><!--#set var="page" value="$1" --><!--#endif -->
<!--#if expr="$file = /.*\/([a-zA-Z0-9\-+_\.]+)/" --><!--#set var="filename" value="$1" --><!--#endif -->
<!--#set var="title" value="${file}" -->
<!--#set var="description" value="File ${filename}" -->
<!--#set var="keywords" value="autodist" -->
<!--#set var="slogan" value="GNU/Linux distribution" -->
<div align=center><h1><img src="/distribution/images/packages_gr.png" style="margin:5px" alt="Package"><!--#echo var=filename --></h1></div>
<div style="display:block;float:left;margin-bottom:10px">Pages:&nbsp;<!--#include virtual="/wp-content/themes/openmamba/cgi-bin/text-to-html-filter-idx.cgi?file=${file}&page=${page}" --></div>
<div style="display:block;float:right"><a href=/download.html?file=<!--#echo var=file -->>DOWNLOAD</a></div>
<div class=downloadbox align=center>
<div align=left style="background-color: white; width: 100%; overflow: auto; font-size: 11pt; border:1px solid #2b6600; margin: 4px; padding:4; background-color: #e0f2d0;">
<pre style="margin:0;border:0"><!--#include virtual="/wp-content/themes/openmamba/cgi-bin/text-to-html-filter.cgi?file=${file}&page=${page}" -->
</pre>
</div>
</div>

View File

@ -0,0 +1,5 @@
<!--#if expr="$QUERY_STRING = /lang=([a-zA-Z0-9\-+_\.]+)/" --><!--#set var="lang" value="$1" --><!--#endif -->
<!--#if expr=$lang --><!--#else --><!--#if expr="$HTTP_ACCEPT_LANGUAGE = /([a-zA-Z0-9]+)/" --><!--#set var="lang" value="$1" --><!--#endif --><!--#endif -->
<!--#if expr="${lang} != it" --><!--#set var="lang" value="en" --><!--#endif -->
<!--#if expr="$QUERY_STRING = /file=([a-zA-Z0-9\-+_\.]+)/" --><!--#set var="lang" value="$1" --><!--#endif -->
<!--#include virtual="showfile.naked.${lang}.html" -->

View File

@ -0,0 +1,18 @@
<!--#if expr="$QUERY_STRING = /file=\([^\&]*\)/" --><!--#set var="file" value="$1" --><!--#endif -->
<!--#if expr="$QUERY_STRING = /page=\([^\&]*\)/" --><!--#set var="page" value="$1" --><!--#endif -->
<!--#if expr="$file = /.*\/([a-zA-Z0-9\-+_\.]+)/" --><!--#set var="filename" value="$1" --><!--#endif -->
<!--#set var="title" value="${filename}" -->
<!--#set var="description" value="File <!--#echo var=file -->" -->
<!--#set var="keywords" value="autodist" -->
<!--#set var="slogan" value="Distribuzione GNU/Linux" -->
<div align=center><h1><img src="/distribution/images/packages_gr.png" style="margin:5px" alt="Pacchetto"><!--#echo var=filename --></h1></div>
<div style="display:block;float:left;margin-bottom:10px">Pagine:&nbsp;<!--#include virtual="/wp-content/themes/openmamba/cgi-bin/text-to-html-filter-idx.cgi?file=${file}&page=${page}" --></div>
<div style="display:block;float:right"><a href=/download.html?file=<!--#echo var=file -->>SCARICA</a></div>
<div class=downloadbox align=center>
<div align=left style="background-color: white; width: 100%; overflow: auto; font-size: 11pt; border:1px solid #2b6600; margin: 4px; padding:4; background-color: #e0f2d0;">
<pre style="margin:0;border:0"><!--#include virtual="/wp-content/themes/openmamba/cgi-bin/text-to-html-filter.cgi?file=${file}&page=${page}" -->
</pre>
</div>
</div>

View File

@ -223,7 +223,7 @@ function openmamba_webbuild_status_func() {
// print "<table width=\"100%\" style=\"border:0;\"><tr><td>"; // print "<table width=\"100%\" style=\"border:0;\"><tr><td>";
print "<div id=\"noajax_msg\"><p>AJAX support is not enabled in your browser. Live page updates will not be available, press Reload to update.</p></div>"; print "<div id=\"noajax_msg\"><p>AJAX support is not enabled in your browser. Live page updates will not be available, press Reload to update.</p></div>";
print "<span class=webbuild id=\"output\">Loading, please wait...</span>"; print "<span class=webbuild id=\"output\">Loading, please wait...</span>";
print "<script>webbuild_status_getvalues(\"" . $urlargs . "\");</script>";//</td></tr></table>"; print "<script>$(document).ready(function(){ webbuild_status_getvalues(\"" . $urlargs . "\"); })</script>";//</td></tr></table>";
} }
add_shortcode('openmamba_webbuild_status', 'openmamba_webbuild_status_func'); add_shortcode('openmamba_webbuild_status', 'openmamba_webbuild_status_func');
@ -240,14 +240,64 @@ function openmamba_distroquery_func() {
else else
$outputlang = "en_US.UTF-8"; $outputlang = "en_US.UTF-8";
$ret = "<div id=\"noajax_msg\"><p>AJAX support is not enabled in your browser. Live page updates will not be available, press Reload to update.</p></div>"; $ret = "<span id=\"queryform\">Loading, please wait...</span><br>";
$ret .= "<br><span id=\"queryform\"></span><br>";
$ret .= "<span id=\"querystatus\"></span><br><span id=\"queryreply\">&nbsp;</span>"; $ret .= "<span id=\"querystatus\"></span><br><span id=\"queryreply\">&nbsp;</span>";
$ret .= "<script>distroquery_request(\"" . $urlargs . "\");</script>"; $ret .= "<script>$(document).ready(function(){ distroquery_request(\"" . $urlargs . "\"); })</script>";
return $ret; return $ret;
} }
add_shortcode('openmamba_distroquery', 'openmamba_distroquery_func'); add_shortcode('openmamba_distroquery', 'openmamba_distroquery_func');
function openmamba_distromatic_func() {
$urlargspos = strpos($_SERVER[REQUEST_URI], '?');
if ($urlargspos > 0) {
$urlargs = substr($_SERVER[REQUEST_URI], $urlargspos + 1);
}
$outputlang = get_bloginfo("language");
if (substr($outputlang, 0, 2) == "it")
$outputlang = "it_IT.UTF-8";
else
$outputlang = "en_US.UTF-8";
$ret = "<span id=\"distromatic\">" . "Loading, please wait..." . "</span><br>";
$ret .= "<script>$(document).ready(function(){ $('#distromatic').load('/distribution/distromatic.naked.html?" . $urlargs . "'); })</script>";
return $ret;
}
add_shortcode('openmamba_distromatic', 'openmamba_distromatic_func');
function openmamba_showfile_func() {
$urlargspos = strpos($_SERVER[REQUEST_URI], '?');
if ($urlargspos > 0) {
$urlargs = substr($_SERVER[REQUEST_URI], $urlargspos + 1);
}
$ret = "<span id=\"distromatic\">" . "Loading, please wait..." . "</span><br>";
$ret .= "<script>$(document).ready(function(){ $('#distromatic').load('/distribution/showfile.naked.html?" . $urlargs . "'); })</script>";
return $ret;
}
add_shortcode('openmamba_showfile', 'openmamba_showfile_func');
function openmamba_downloadfile_func() {
$urlargspos = strpos($_SERVER[REQUEST_URI], '?');
if ($urlargspos > 0) {
$urlargs = substr($_SERVER[REQUEST_URI], $urlargspos + 1);
parse_str($urlargs, $args);
if ($args['file']) {
$ret = "<span id=\"distromatic\">" . "Starting download of <strong>" . basename($args['file']) . "</strong>, please wait..." . "</span><br><br>";
$ret .= "<script>$(document).ready(function(){ window.location.href='" . $args['file'] . "'; })</script>";
}
}
return $ret;
}
add_shortcode('openmamba_downloadfile', 'openmamba_downloadfile_func');
// bbpress tag cloud // bbpress tag cloud
add_filter('widget_tag_cloud_args','set_number_tags'); add_filter('widget_tag_cloud_args','set_number_tags');
function set_number_tags($args) { function set_number_tags($args) {

View File

@ -239,3 +239,23 @@ div#ag-terms {
margin-top:10px; margin-top:10px;
margin-bottom:10px; margin-bottom:10px;
} }
/* Distromatic */
span#distromatic table,
span#distromatic table tr,
span#distromatic table td {
padding:0;
border:0;
}
span#distromatic table td img {
max-width:initial;
padding: 2px;
}
span#distromatic table td hr {
margin: 0;
margin-top: 5px;
margin-bottom: 5px;
}