Merge pull request #2939 from FinnStutzenstein/Encoding
Added UTF-8 byte order mark for csv export
This commit is contained in:
commit
311b134d81
@ -46,6 +46,7 @@ Core:
|
||||
- Added watching permissions in client and change the view immediately on changes.
|
||||
- Validate HTML strings from CKEditor against XSS attacks.
|
||||
- Added success/error symbol to config to show if saving was successful.
|
||||
- Added UTF-8 byte order mark for every CSV export.
|
||||
|
||||
Motions:
|
||||
- Added adjustable line numbering mode (outside, inside, none) for each
|
||||
|
@ -16,7 +16,7 @@ angular.module('OpenSlidesApp.agenda.csv', [])
|
||||
});
|
||||
};
|
||||
return {
|
||||
export: function (element, agenda) {
|
||||
export: function (agenda) {
|
||||
var csvRows = [
|
||||
makeHeaderline()
|
||||
];
|
||||
@ -32,7 +32,7 @@ angular.module('OpenSlidesApp.agenda.csv', [])
|
||||
row.push('"' + (item.is_hidden ? '1' : '') + '"');
|
||||
csvRows.push(row);
|
||||
});
|
||||
CsvDownload(csvRows, element, 'agenda-export.csv');
|
||||
CsvDownload(csvRows, 'agenda-export.csv');
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -270,8 +270,7 @@ angular.module('OpenSlidesApp.agenda.site', [
|
||||
PdfCreate.download(documentProvider.getDocument(), filename);
|
||||
};
|
||||
$scope.csvExport = function () {
|
||||
var element = document.getElementById('downloadLinkCSV');
|
||||
AgendaCsvExport.export(element, $scope.itemsFiltered);
|
||||
AgendaCsvExport.export($scope.itemsFiltered);
|
||||
};
|
||||
|
||||
/** select mode functions **/
|
||||
|
@ -105,6 +105,16 @@ def get_config_variables():
|
||||
group='General',
|
||||
subgroup='System')
|
||||
|
||||
# CSV
|
||||
|
||||
yield ConfigVariable(
|
||||
name='general_csv_separator',
|
||||
default_value=',',
|
||||
label='The separator used for the csv export and examples',
|
||||
weight=144,
|
||||
group='General',
|
||||
subgroup='CSV')
|
||||
|
||||
# Projector
|
||||
|
||||
yield ConfigVariable(
|
||||
|
@ -5,19 +5,17 @@
|
||||
angular.module('OpenSlidesApp.core.csv', [])
|
||||
|
||||
.factory('CsvDownload', [
|
||||
function () {
|
||||
return function (contentRows, element, fileName) {
|
||||
if (navigator.msSaveBlob && typeof navigator.msSaveBlob === 'function') {
|
||||
// Bad browsers
|
||||
var blob = new Blob([contentRows.join('\r\n')]);
|
||||
navigator.msSaveBlob(blob, fileName);
|
||||
} else { // Good browsers
|
||||
// %0A is the url encoded linefeed character. Needed to be
|
||||
// percentage encoded for the data url.
|
||||
element.href = 'data:text/csv;charset=utf-8,' + contentRows.join('%0A');
|
||||
element.download = fileName;
|
||||
element.target = '_blank';
|
||||
}
|
||||
'Config',
|
||||
'FileSaver',
|
||||
function (Config, FileSaver) {
|
||||
var utf8_BOM = decodeURIComponent('%EF%BB%BF');
|
||||
return function (contentRows, filename) {
|
||||
var separator = Config.get('general_csv_separator').value;
|
||||
var rows = _.map(contentRows, function (row) {
|
||||
return row.join(separator);
|
||||
});
|
||||
var blob = new Blob([utf8_BOM + rows.join('\n')]);
|
||||
FileSaver.saveAs(blob, filename);
|
||||
};
|
||||
}
|
||||
]);
|
||||
|
@ -15,7 +15,7 @@ angular.module('OpenSlidesApp.motions.csv', [])
|
||||
});
|
||||
};
|
||||
return {
|
||||
export: function (element, motions) {
|
||||
export: function (motions) {
|
||||
var csvRows = [
|
||||
makeHeaderline()
|
||||
];
|
||||
@ -32,16 +32,16 @@ angular.module('OpenSlidesApp.motions.csv', [])
|
||||
row.push('"' + motion.origin + '"');
|
||||
csvRows.push(row);
|
||||
});
|
||||
CsvDownload(csvRows, element, 'motions-export.csv');
|
||||
CsvDownload(csvRows, 'motions-export.csv');
|
||||
},
|
||||
downloadExample: function (element) {
|
||||
downloadExample: function () {
|
||||
var csvRows = [makeHeaderline(),
|
||||
// example entries
|
||||
['A1', 'Title 1', 'Text 1', 'Reason 1', 'Submitter A', 'Category A', 'Last Year Conference A'],
|
||||
['B1', 'Title 2', 'Text 2', 'Reason 2', 'Submitter B', 'Category B', ''],
|
||||
['' , 'Title 3', 'Text 3', '', '', '', ''],
|
||||
];
|
||||
CsvDownload(csvRows, element, 'motions-example.csv');
|
||||
CsvDownload(csvRows, 'motions-example.csv');
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -880,8 +880,7 @@ angular.module('OpenSlidesApp.motions.site', [
|
||||
|
||||
// Export as a csv file
|
||||
$scope.csvExport = function () {
|
||||
var element = document.getElementById('downloadLinkCSV');
|
||||
MotionCsvExport.export(element, $scope.motionsFiltered);
|
||||
MotionCsvExport.export($scope.motionsFiltered);
|
||||
};
|
||||
// Export as docx file
|
||||
$scope.docxExport = function () {
|
||||
@ -1746,8 +1745,7 @@ angular.module('OpenSlidesApp.motions.site', [
|
||||
};
|
||||
// download CSV example file
|
||||
$scope.downloadCSVExample = function () {
|
||||
var element = document.getElementById('downloadLink');
|
||||
MotionCsvExport.downloadExample(element);
|
||||
MotionCsvExport.downloadExample();
|
||||
};
|
||||
}
|
||||
])
|
||||
|
@ -15,7 +15,7 @@ angular.module('OpenSlidesApp.topics.csv', [])
|
||||
});
|
||||
};
|
||||
return {
|
||||
downloadExample: function (element) {
|
||||
downloadExample: function () {
|
||||
var csvRows = [makeHeaderline(),
|
||||
// example entries
|
||||
['Demo 1', 'Demo text 1', '1:00', 'test comment', ''],
|
||||
@ -23,7 +23,7 @@ angular.module('OpenSlidesApp.topics.csv', [])
|
||||
['Demo 2', 'Demo text 2', '1:30', '', '']
|
||||
|
||||
];
|
||||
CsvDownload(csvRows, element, 'agenda-example.csv');
|
||||
CsvDownload(csvRows, 'agenda-example.csv');
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -372,8 +372,7 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics', 'OpenSlides
|
||||
};
|
||||
// download CSV example file
|
||||
$scope.downloadCSVExample = function () {
|
||||
var element = document.getElementById('downloadLink');
|
||||
TopicsCsvExample.downloadExample(element);
|
||||
TopicsCsvExample.downloadExample();
|
||||
};
|
||||
}
|
||||
]);
|
||||
|
@ -17,7 +17,7 @@ angular.module('OpenSlidesApp.users.csv', [])
|
||||
});
|
||||
};
|
||||
return {
|
||||
export: function (element, users) {
|
||||
export: function (users) {
|
||||
var csvRows = [
|
||||
makeHeaderline()
|
||||
];
|
||||
@ -38,10 +38,10 @@ angular.module('OpenSlidesApp.users.csv', [])
|
||||
row.push(user.is_committee ? '1' : '0');
|
||||
csvRows.push(row);
|
||||
});
|
||||
CsvDownload(csvRows, element, 'users-export.csv');
|
||||
CsvDownload(csvRows, 'users-export.csv');
|
||||
},
|
||||
|
||||
downloadExample: function (element) {
|
||||
downloadExample: function () {
|
||||
// try to get an example with two groups and one with one group
|
||||
var groups = Group.getAll();
|
||||
var csvGroups = '';
|
||||
@ -62,7 +62,7 @@ angular.module('OpenSlidesApp.users.csv', [])
|
||||
['', '', 'Executive Board', '', '', '', '', '', '', '1'],
|
||||
|
||||
];
|
||||
CsvDownload(csvRows, element, 'users-example.csv');
|
||||
CsvDownload(csvRows, 'users-example.csv');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -636,8 +636,7 @@ angular.module('OpenSlidesApp.users.site', [
|
||||
};
|
||||
// Export as a csv file
|
||||
$scope.csvExport = function () {
|
||||
var element = document.getElementById('downloadLinkCSV');
|
||||
UserCsvExport.export(element, $scope.usersFiltered);
|
||||
UserCsvExport.export($scope.usersFiltered);
|
||||
};
|
||||
}
|
||||
])
|
||||
@ -1086,8 +1085,7 @@ angular.module('OpenSlidesApp.users.site', [
|
||||
};
|
||||
// download CSV example file
|
||||
$scope.downloadCSVExample = function () {
|
||||
var element = document.getElementById('downloadLink');
|
||||
UserCsvExport.downloadExample(element);
|
||||
UserCsvExport.downloadExample();
|
||||
};
|
||||
}
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user