update.php 3.18 KB
Newer Older
1 2
<?php

3 4 5 6
if (php_sapi_name() !== 'cli') {
    exit('The update script must be run from the command line');
}

7
$urls = [
8 9 10 11 12 13 14 15
    // extract
    'https://gitlab.coko.foundation/XSweet/XSweet/raw/master/applications/docx-extract/EXTRACT-docx.xsl',
      'https://gitlab.coko.foundation/XSweet/XSweet/raw/master/applications/docx-extract/docx-html-extract.xsl',
        'https://gitlab.coko.foundation/XSweet/XSweet/raw/master/applications/docx-extract/docx-table-extract.xsl',
      'https://gitlab.coko.foundation/XSweet/XSweet/raw/master/applications/docx-extract/handle-notes.xsl',
      'https://gitlab.coko.foundation/XSweet/XSweet/raw/master/applications/docx-extract/scrub.xsl',
      'https://gitlab.coko.foundation/XSweet/XSweet/raw/master/applications/docx-extract/join-elements.xsl',
      'https://gitlab.coko.foundation/XSweet/XSweet/raw/master/applications/docx-extract/collapse-paragraphs.xsl',
16

17 18
    // links
    'https://gitlab.coko.foundation/XSweet/XSweet/raw/master/applications/local-fixup/hyperlink-inferencer.xsl',
19

20 21 22 23
    // lists
    'https://gitlab.coko.foundation/XSweet/XSweet/raw/master/applications/list-promote/PROMOTE-lists.xsl',
      'https://gitlab.coko.foundation/XSweet/XSweet/raw/master/applications/list-promote/itemize-lists.xsl',
      'https://gitlab.coko.foundation/XSweet/XSweet/raw/master/applications/list-promote/mark-lists.xsl',
24

25 26 27 28 29 30
    // header choose and promote
    'https://gitlab.coko.foundation/XSweet/HTMLevator/raw/master/applications/header-promote/header-promotion-CHOOSE.xsl',
      'https://gitlab.coko.foundation/XSweet/HTMLevator/raw/master/applications/header-promote/make-header-mapper-xslt.xsl',
      'https://gitlab.coko.foundation/XSweet/HTMLevator/raw/master/applications/header-promote/outline-headers.xsl',
      'https://gitlab.coko.foundation/XSweet/HTMLevator/raw/master/applications/header-promote/digest-paragraphs.xsl',
      'https://gitlab.coko.foundation/XSweet/HTMLevator/raw/master/applications/header-promote/make-header-escalator-xslt.xsl',
31

32 33
    // rinse
    'https://gitlab.coko.foundation/XSweet/XSweet/raw/master/applications/html-polish/final-rinse.xsl',
34

35 36 37 38 39 40
    // ucp cleanup macro and typescript
    'https://gitlab.coko.foundation/XSweet/editoria_typescript/raw/master/editoria-tune.xsl',
    'https://gitlab.coko.foundation/XSweet/editoria_typescript/raw/master/p-split-around-br.xsl',
    'https://gitlab.coko.foundation/XSweet/editoria_typescript/raw/master/editoria-notes.xsl',
    'https://gitlab.coko.foundation/XSweet/editoria_typescript/raw/master/editoria-basic.xsl',
    'https://gitlab.coko.foundation/XSweet/editoria_typescript/raw/master/editoria-reduce.xsl',
41 42
];

43
$outputDir = '/var/www/html/xsl';
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

if (!file_exists($outputDir)) {
    mkdir($outputDir);
}

foreach ($urls as $url) {
    $input = fopen($url, 'r');
    if (!$input) {
        exit("Failed opening $url\n");
    }

    $outputPath = $outputDir . '/' . basename($url);
    $output = fopen($outputPath, 'w');
    if (!$output) {
        exit("Failed opening $outputPath\n");
    }

    print("Copying $url to $outputPath\n");
    $result = stream_copy_to_stream($input, $output);
    if (!$result) {
        exit("Failed copying $url to $outputPath\n");
    }

    fclose($input);
    fclose($output);
}