Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
VascoRatoFCCN committed Dec 19, 2022
2 parents 9f5ebe6 + 94560f7 commit 3dd5697
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 9 deletions.
28 changes: 28 additions & 0 deletions public/css/styles-citation-saver.css
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,32 @@ section#citation-saver-modal form {

section#citation-saver-modal form button {
width: 103px;
}

#citation-saver-main > p{
line-height: 24px;
font-family: "Roboto", sans-serif;
font-size: 16px;
margin-block-end: 24px;
margin-bottom: 24px;
}

#input-file-selector {
display: inline-block;
width: 100%;
background-color: white;
border-radius: 5px;
border-color: #C4C4C4;
border-width: 1px;
border-style: solid;
padding: 0 11px 0 0;
line-height: 42px;
}
#input-file-button {
line-height: 29px;
}
#input-file-text {
color: gray;
vertical-align: middle;
margin-left: 6px;
}
11 changes: 11 additions & 0 deletions public/js/citation-saver.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,15 @@ $(() => {
});

});
});

function getFile() {
}

$(document).on("click", "#input-file-selector", function(e) {
e.preventDefault();
$("#input-file-file").click();
});
$(document).on("input", "input:file", function(e) {
$("#input-file-text").text(e.target.files[0].name);
});
15 changes: 10 additions & 5 deletions src/services-citationsaver.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ const logger = require('./logger')('CitationSaver');

// Initialize the sheet - doc ID is the long id in the sheets URL
async function addToSpreadsheet(row) {
const doc = new GoogleSpreadsheet(googleSheetId);
await doc.useServiceAccountAuth(serviceAccountConfigs)
try {
const doc = new GoogleSpreadsheet(googleSheetId);
await doc.useServiceAccountAuth(serviceAccountConfigs)

await doc.loadInfo();
const sheet = doc.sheetsByIndex[0]; // or use doc.sheetsById[id] or doc.sheetsByTitle[title]
await sheet.addRow(row);
await doc.loadInfo();
const sheet = doc.sheetsByIndex[0]; // or use doc.sheetsById[id] or doc.sheetsByTitle[title]
await sheet.addRow(row);
} catch (err) {
logger.error('Failed to connect to google services. Reason: "'+ err + '". Data: '+JSON.stringify(row));
}

}

const mimeToExtension = {
Expand Down
8 changes: 8 additions & 0 deletions translations/services-citation-saver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ url:
upload:
en: "Upload a document from your computer:"
pt: 'Carregue um documento a partir do seu computador:'
upload-selection:
button:
en: Select a file
pt: Selecione um ficheiro
default-text:
en: No file selected
pt: Nenhum ficheiro selecionado

text:
en: "Insert a text containing URLs:"
pt: 'Insira um texto contendo URLs:'
Expand Down
16 changes: 12 additions & 4 deletions views/templates/body/body-services-citation-saver.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<img id="logo-citation-saver" class="image-width" src="/img/CitationSaver.svg" alt="CitationSaver">
<h4 id="save-page-now-slogan"><%= t('services-citation-saver.slogan') %></h4>

<p style="line-height: 27px;margin-top: 20px;"><%- t('services-citation-saver.description.1') %></p>
<p style="line-height: 27px;"><%- t('services-citation-saver.description.2') %></p>
<p style="line-height: 27px;"><%- t('services-citation-saver.description.3') %></p>
<p style="margin-top: 20px;"><%- t('services-citation-saver.description.1') %></p>
<p><%- t('services-citation-saver.description.2') %></p>
<p><%- t('services-citation-saver.description.3') %></p>

<div class="citation-saver-input-selection">
<input type="radio" name="input-selection" id="input-url" checked="checked">
Expand All @@ -26,8 +26,16 @@
<label for="input-file-upload"><%- t('services-citation-saver.tab.2') %></label>
<div class="input-tab">
<form action="/services/citationsaver" method="post" enctype="multipart/form-data">

<label for="input-file-file"><%- t('services-citation-saver.upload') %></label>
<input type="file" name="file" id="input-file-file">
<div id="input-file-selector">
<button id="input-file-button" class="button" type="button"><%- t('services-citation-saver.upload-selection.button') %></button>
<span id="input-file-text"><%- t('services-citation-saver.upload-selection.default-text') %></span>
</div>
<div style='height: 0px;width:0px; overflow:hidden;'>
<input type="file" name="file" id="input-file-file" style="visibility:hidden">
</div>
<!-- here you can have file submit button or you can write a simple script to upload the file automatically-->
<small><%- t('services-citation-saver.field.1') %></small>


Expand Down

0 comments on commit 3dd5697

Please sign in to comment.