Last active
August 29, 2015 14:04
-
-
Save emanuele45/e7f7e73d05172da5981c to your computer and use it in GitHub Desktop.
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
<downloadtable> | |
{ | |
"version": "4.1.0", | |
"version_short": "4.1.0", | |
"milestone": "AOO410m18", | |
"build": "9764", | |
"svn_rev": "r1589052", | |
"rel_date": "2014-Apr-29", | |
"prev_version": "4.0.1", | |
"oldversion": "3.4.1", | |
"legacyversion": "3.3.0", | |
"sf": "http://sourceforge.net/projects/openofficeorg.mirror/files/", | |
"asf": "http://www.apache.org/dyn/aoo-closer.cgi/openoffice/", | |
"asf_dist": "http://www.apache.org/dist/openoffice/", | |
"asf_arc": "http://archive.apache.org/dist/openoffice/", | |
"beta_version": "4.1.1", | |
"rel_platforms": [ | |
{"name": "Win_x86", "postfix": "", "ext": "exe", "dlname": "exe", "header": "Windows <br \/>Intel <br \/>EXE"}, | |
{"name": "Linux_x86", "postfix": "-rpm", "ext": "tar.gz", "dlname": "rpm", "header": "Linux <br \/>Intel <br \/>RPM"}, | |
{"name": "Linux_x86", "postfix": "-deb", "ext": "tar.gz", "dlname": "deb", "header": "Linux <br \/>Intel <br \/>DEB"}, | |
{"name": "Linux_x86-64", "postfix": "-rpm", "ext": "tar.gz", "dlname": "rpm", "header": "Linux <br \/>x86-64<br \/>RPM"}, | |
{"name": "Linux_x86-64", "postfix": "-deb", "ext": "tar.gz", "dlname": "deb", "header": "Linux <br \/>x86-64<br \/>DEB"}, | |
{"name": "MacOS_x86-64", "postfix": "", "ext": "dmg", "dlname": "dmg", "header": "OS X <br \/>x86-64<br \/>DMG"} | |
], | |
"langs": [ | |
{"code": "ast", "en": "Asturian", "full": "1", "langpack": "1", "native": "Asturianu"}, | |
{"code": "eu", "en": "Basque", "full": "1", "langpack": "1", "native": "Euskara"}, | |
{"code": "bg", "en": "Bulgarian", "full": "1", "langpack": "1", "native": "български език"}, | |
{"code": "zh-CN", "en": "Chinese (simplified)", "full": "1", "langpack": "1", "native": "简体中文"}, | |
{"code": "zh-TW", "en": "Chinese (traditional)", "full": "1", "langpack": "1", "native": "正體中文"}, | |
{"code": "cs", "en": "Czech", "full": "1", "langpack": "1", "native": "Čeština"}, | |
{"code": "da", "en": "Danish", "full": "1", "langpack": "1", "native": "Dansk"}, | |
{"code": "nl", "en": "Dutch", "full": "1", "langpack": "1", "native": "Nederlands"}, | |
{"code": "en-GB", "en": "English (GB)", "full": "1", "langpack": "1", "native": "English (British)"}, | |
{"code": "en-US", "en": "English (US)", "full": "1", "langpack": "1", "native": "English (US)"}, | |
{"code": "fi", "en": "Finnish", "full": "1", "langpack": "1", "native": "Suomi"}, | |
{"code": "fr", "en": "French", "full": "1", "langpack": "1", "native": "Français"}, | |
{"code": "gd", "en": "Gaelic<br \/>(Scottish)", "full": "1", "langpack": "1", "native": "Gàidhlig"}, | |
{"code": "gl", "en": "Galician", "full": "1", "langpack": "1", "native": "Galego"}, | |
{"code": "de", "en": "German", "full": "1", "langpack": "1", "native": "Deutsch"}, | |
{"code": "el", "en": "Greek", "full": "1", "langpack": "1", "native": "Ελληνικά"}, | |
{"code": "he", "en": "Hebrew", "full": "1", "langpack": "1", "native": "עִבְרִית"}, | |
{"code": "hi", "en": "Hindi", "full": "1", "langpack": "1", "native": "हिन्दी"}, | |
{"code": "hu", "en": "Hungarian", "full": "1", "langpack": "1", "native": "Magyar"}, | |
{"code": "it", "en": "Italian", "full": "1", "langpack": "1", "native": "Italiano"}, | |
{"code": "ja", "en": "Japanese", "full": "1", "langpack": "1", "native": "日本語"}, | |
{"code": "km", "en": "Khmer", "full": "1", "langpack": "1", "native": "ភាសាខ្មែរ"}, | |
{"code": "ko", "en": "Korean", "full": "1", "langpack": "1", "native": "한국어"}, | |
{"code": "lt", "en": "Lithuanian", "full": "1", "langpack": "1", "native": "Lietuvių"}, | |
{"code": "nb", "en": "Norwegian<br \/>(Bokmal)", "full": "1", "langpack": "1", "native": "Norsk<br \/>(Bokmål)"}, | |
{"code": "pl", "en": "Polish", "full": "1", "langpack": "1", "native": "Polski"}, | |
{"code": "pt-BR", "en": "Portuguese (Brazilian)", "full": "1", "langpack": "1", "native": "Português (do Brasil)"}, | |
{"code": "pt", "en": "Portuguese (European)", "full": "1", "langpack": "1", "native": "Português (Europeu)"}, | |
{"code": "ru", "en": "Russian", "full": "1", "langpack": "1", "native": "Русский"}, | |
{"code": "sr", "en": "Serbian<br \/>(Cyrillic)", "full": "1", "langpack": "1", "native": "Cрпски<br \/>(ћирилицом)"}, | |
{"code": "sk", "en": "Slovak", "full": "1", "langpack": "1", "native": "Slovenský<br \/>jazyk (slovenčina)"}, | |
{"code": "sl", "en": "Slovenian", "full": "1", "langpack": "1", "native": "Slovenski<br \/>jezik (slovenščina)"}, | |
{"code": "es", "en": "Spanish", "full": "1", "langpack": "1", "native": "Español"}, | |
{"code": "sv", "en": "Swedish", "full": "1", "langpack": "1", "native": "Svenska"}, | |
{"code": "ta", "en": "Tamil", "full": "1", "langpack": "1", "native": "தமிழ்"}, | |
{"code": "th", "en": "Thai", "full": "1", "langpack": "1", "native": "ภาษาไทย"}, | |
{"code": "tr", "en": "Turkish", "full": "1", "langpack": "1", "native": "Türkçe"}, | |
{"code": "vi", "en": "Vietnamese", "full": "1", "langpack": "1", "native": "Tiếng Việt"} | |
] | |
} | |
</downloadtable> |
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
... | |
[qr!other.html$!, download_others => { template => "html_page.html" }], | |
... |
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
sub write_table() { | |
my $content = $_[0]; | |
my $rel_mode = 1; | |
my $jsonc = ''; | |
if ($content =~ m!<downloadtable>(.*?)</downloadtable>!si) { | |
$jsonc = create_dl_table($1); | |
$content =~ s/<downloadtable>(.*?)<\/downloadtable>/$jsonc/si; | |
} | |
return $content; | |
} | |
sub create_dl_table() { | |
my $jsonc = shift; | |
my $json = new JSON; | |
# these are some nice json options to relax restrictions a bit: | |
my $json_text = $json->allow_nonref->utf8->relaxed->escape_slash->loose->allow_singlequote->allow_barekey->decode($jsonc); | |
my $content = " | |
<table> | |
<thead> | |
<tr> | |
<th colspan=\"2\">Language<br />The names do not refer to countries.</th> | |
<th>Types</th>"; | |
$content .= write_row($json_text->{rel_platforms}); | |
$content .= " | |
</tr> | |
</thead> | |
<tbody>"; | |
foreach my $language (@{$json_text->{langs}}) { | |
$content .= " | |
<tr>" . write_row($json_text->{rel_platforms}, $language, $json_text->{version}, $json_text->{sf}, $json_text->{asf_arc}) . " | |
</tr>"; | |
} | |
$content .= " | |
</tbody> | |
</table>"; | |
# $content .= write_row(0, @rows); | |
return $content; | |
} | |
sub write_row() { | |
# my $FIRST_HEADER = $_[1]; | |
# my @args = @_; | |
my $platform_obj = shift; | |
my $lang_obj = shift; | |
my $version = shift; | |
my $base_url = shift; | |
my $asf_arc = shift; | |
# for(my $i = 1; $i < scalar(@args); $i++) { | |
# $values[$i - 1] = $args[$i]; | |
# } | |
my $SMALL1 = ""; | |
my $SMALL2 = ""; | |
my $return = ""; | |
# // If it's the first header at the top of a table use a normal font size | |
# // But use a smaller font size for further headers within the table | |
if ( not defined($lang_obj) ) { | |
# $return .= "<th>" ; | |
foreach my $val (@{$platform_obj}) { | |
$return .= " | |
<th>" . $val->{header} . "</th>"; | |
} | |
# | |
# $return .= "\n| " ; | |
# foreach my $val (@{$platform_obj}) { | |
# $return .= " ----------------- |"; | |
# } | |
} else { | |
# $return .= "| " ; | |
$return .= " | |
<td> | |
<small>" . $lang_obj->{en} . "</small> | |
</td>"; | |
$return .= " | |
<td> | |
<small>" . $lang_obj->{native} . "</small> | |
</td>"; | |
if ($lang_obj->{full} == 1) | |
{ | |
$return .= " | |
<td> | |
Full Install | |
</td>"; | |
$return .= write_dl_array('install', $platform_obj, $lang_obj, 'Apache_OpenOffice_', $version, $base_url, $asf_arc); | |
} | |
if ($lang_obj->{langpack} == 1) | |
{ | |
if ($lang_obj->{full} == 1) { | |
$return .= " | |
</tr> | |
<tr> | |
<td></td> | |
<td></td>"; | |
} | |
$return .= " | |
<td>Langpack</td>"; | |
$return .= write_dl_array('langpack', $platform_obj, $lang_obj, 'Apache_OpenOffice_', $version, $base_url, $asf_arc); | |
} | |
} | |
return $return . "\n"; | |
} | |
sub write_dl_array() | |
{ | |
my $type = shift; | |
my $platform_obj = shift; | |
my $lang_obj = shift; | |
my $base_name = shift; | |
my $version = shift; | |
my $base_url = shift; | |
my $asf_arc = shift; | |
my $return = ""; | |
my @hashes = ('asc', 'md5', 'sha256'); | |
foreach my $val (@{$platform_obj}) { | |
$return .= " | |
<td> | |
<a href=\"" . $base_url . $version . '/binaries/' . $lang_obj->{code} . '/' . $base_name . $version . '_' . $val->{name} . '_' . $type . $val->{postfix} . '_' . $lang_obj->{code} . '.' . $val->{ext} . "/download\"> | |
<b>" . $val->{dlname} . "</b> | |
</a> | |
<br> | |
<br>"; | |
my $count = 0; | |
foreach my $hash (@hashes) { | |
$return .= " | |
<a class=\"hashes\" href=\"" . $asf_arc . $version . '/binaries/' . $lang_obj->{code} . '/' . $base_name . $version . '_' . $val->{name} . '_' . $type . $val->{postfix} . '_' . $lang_obj->{code} . '.' . $val->{ext} . "." . $hash . "\">" . uc($hash) . "</a>"; | |
if ($count == 1) { | |
$return .= " | |
<br>"; | |
} | |
$count++; | |
} | |
$return .= " | |
</td>"; | |
} | |
return $return; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment