Ignore:
Timestamp:
2021-12-08T13:55:18+13:00 (2 years ago)
Author:
cstephen
Message:

Upgrade to support the new macroniser backend.
Fix chunk/asset resolution

Location:
main/trunk/model-interfaces-dev/atea/macron-restoration
Files:
3 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/atea/macron-restoration/src/components/DirectInput.vue

    r35760 r35772  
    130130                }
    131131
    132                 if (word.linebreak) {
    133                     restored += this.normaliseLinebreak(word.linebreak);
     132                if (word.linebreaks) {
     133                    restored += this.normaliseLinebreak(word.linebreaks);
    134134                }
    135135            }
     
    187187        /**
    188188         * Normalises a linebreak.
    189          * @param {String} linebreak The linebreak sequence.
     189         * @param {String} linebreakCount The linebreak sequence.
    190190         */
    191         normaliseLinebreak(linebreak) {
     191        normaliseLinebreak(linebreakCount) {
    192192            if (!this.normaliseLinebreaks) {
    193                 return linebreak;
    194             }
    195 
    196             const rCount = linebreak.split("\r").length - 1;
    197             const nCount = linebreak.split("\n").length - 1;
    198 
    199             if (rCount > 1) {
    200                 if (nCount > 0) {
    201                     return "\r\n\r\n";
    202                 }
    203 
    204                 return "\r\r";
    205             }
    206             else if (nCount > 1) {
    207                 return "\n\n";
    208             }
    209 
    210             return linebreak;
     193                return this.repeatString("\n", linebreakCount);
     194            }
     195
     196            linebreakCount = Math.min(2, linebreakCount);
     197            return this.repeatString("\n", linebreakCount);
     198        },
     199        repeatString(string, count) {
     200            let result = "";
     201
     202            for (let i = 0; i < count; i++) {
     203                result += string;
     204            }
     205
     206            return result;
    211207        }
    212208    }
  • main/trunk/model-interfaces-dev/atea/macron-restoration/src/components/FileInput.vue

    r35727 r35772  
    55    <div v-for="(fileInfo, index) in fileInfos" :key="fileInfo.id">
    66        <div class="info-container">
    7             <img class="icon-l" src="img/word_icon.ico" v-if="fileInfo.fileType === '.docx'" />
    8             <img class="icon-l" src="img/powerpoint_icon.ico" v-else-if="fileInfo.fileType === '.pptx'" />
     7            <img class="icon-l" src="../assets/word_icon.webp" v-if="fileInfo.fileType === '.docx'" />
     8            <img class="icon-l" src="../assets/powerpoint_icon.webp" v-else-if="fileInfo.fileType === '.pptx'" />
    99            <span class="material-icons mdi-override" v-else>description</span>
    1010
     
    8585    },
    8686    mounted() {
    87         this.$refs.formDownload.setAttribute("action", macronRestorer.queryUrl + "Download");
     87        this.$refs.formDownload.setAttribute("action", macronRestorer.rootQueryUrl + "download");
    8888    }
    8989}
  • main/trunk/model-interfaces-dev/atea/macron-restoration/src/components/FileUpload.vue

    r35726 r35772  
    99
    1010            <input ref="fileInput" type="file" @input="onFilesChanged"
    11                 accept="application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.oasis.opendocument.text,text/plain,application/vnd.openxmlformats-officedocument.presentationml.presentation"
     11                accept="application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.oasis.opendocument.text,text/plain,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
    1212                multiple :disabled="isMacronising" />
    1313
  • main/trunk/model-interfaces-dev/atea/macron-restoration/src/js/MacronRestorationModule.js

    r35723 r35772  
    3333        /** @type {String} The URL to which query POST requests should be made. */
    3434        if (process.env.NODE_ENV !== "production") {
    35             this.queryUrl = "//localhost:8383/macron-restoration/jsp/servlet/";
     35            this.rootQueryUrl = "//localhost:8383/gs3-macroniser/";
    3636        }
    3737        else {
    38             this.queryUrl = "/macron-restoration/jsp/servlet/";
     38            this.rootQueryUrl = "/gs3-macroniser/";
    3939        }
    4040    }
     
    4343     * Performs a request to the macron restoration API to restore the given input text.
    4444     * @param {String} input The input text to macronise
    45      * @returns {Promise<{ w: String, macronised?: Boolean }>} The JSON response from the macron restoration API.
     45     * @returns {Promise<{ w?: String, macronised?: Boolean, linebreaks?: Number }>} The JSON response from the macron restoration API.
    4646     */
    4747    async directMacronisation(input, preserveExistingMacrons) {
    48         const queryUrl = this.queryUrl + "DirectInput";
     48        const queryUrl = this.rootQueryUrl + "direct";
     49
     50        const formData = new FormData();
     51        formData.append("fragment", input);
     52        formData.append("preserveExistingMacrons", preserveExistingMacrons);
    4953
    5054        try {
     
    5357                {
    5458                    method: "POST",
    55                     headers: {
    56                         "Content-Type": "application/x-www-form-urlencoded"
    57                     },
    58                     body: `o=json&fragment=${input}&preserveExistingMacrons=${preserveExistingMacrons}`
     59                    body: formData
    5960                }
    6061            );
     
    8283     */
    8384    async fileMacronisation(file, preserveExistingMacrons) {
    84         const queryUrl = this.queryUrl + "FileUpload";
     85        const queryUrl = this.rootQueryUrl + "file";
    8586        const formData = new FormData();
    8687
  • main/trunk/model-interfaces-dev/atea/macron-restoration/vue.config.js

    r35714 r35772  
    55 */
    66module.exports = {
    7     // publicPath: "interfaces/atea/macron-restoration/dist",
    87    filenameHashing: false, // Allows us to easily setup direct links to the bundles in macron-restoration.xsl. You may want to change this for production in order to help with caching
     8    publicPath: process.env.NODE_ENV === 'production'
     9        ? '/greenstone3/interfaces/atea/macron-restoration/dist'
     10        : '/',
    911
    1012    chainWebpack: config => {
Note: See TracChangeset for help on using the changeset viewer.