Skip to content

Commit 9189a03

Browse files
authored
Merge pull request #20 from jekuer/devops
Devops
2 parents e734652 + 3edee87 commit 9189a03

File tree

12 files changed

+2593
-182
lines changed

12 files changed

+2593
-182
lines changed

Gruntfile.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
module.exports = function(grunt) {
2+
3+
// The config.
4+
grunt.initConfig({
5+
clean: { // cleans old built files
6+
oldBuildFiles: ['assets/js/atcb.min.js', 'assets/js/atcb.min.js.map', 'assets/css/atcb.min.css', 'assets/css/atcb.min.css.map', 'npm_dist/']
7+
},
8+
copy: {
9+
npm_dist: { // creates the source file for the npm version
10+
src: 'assets/js/atcb.js',
11+
dest: 'npm_dist/atcb_npm.js',
12+
options: {
13+
process: function (content) {
14+
return content.replace(/\/\/ START INIT[\s\S]*?\/\/ END INIT/g,"export { atcb_init };");
15+
}
16+
}
17+
}
18+
},
19+
uglify: { // minifies the main js file
20+
options: {
21+
compress: true,
22+
mangle: true,
23+
sourceMap: true
24+
},
25+
newBuild: {
26+
files: {
27+
'assets/js/atcb.min.js': ['assets/js/atcb.js']
28+
}
29+
}
30+
},
31+
cssmin: {
32+
options: {
33+
sourceMap: true
34+
},
35+
newBuild: {
36+
files: {
37+
'assets/css/atcb.min.css': ['assets/css/atcb.css']
38+
}
39+
}
40+
}
41+
});
42+
43+
// Load the plugins.
44+
grunt.loadNpmTasks('grunt-contrib-copy');
45+
grunt.loadNpmTasks('grunt-contrib-clean');
46+
grunt.loadNpmTasks('grunt-contrib-uglify');
47+
grunt.loadNpmTasks('grunt-contrib-cssmin');
48+
49+
// Register task(s).
50+
grunt.registerTask('default', ['clean', 'copy', 'uglify', 'cssmin']);
51+
52+
};

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ Anyone is welcome to contribute, but mind the [guidelines](.github/CONTRIBUTING.
190190
* [Bug reports](.github/CONTRIBUTING.md#bugs)
191191
* [Feature requests](.github/CONTRIBUTING.md#features)
192192
* [Pull requests](.github/CONTRIBUTING.md#pull-requests)
193+
194+
IMPORTANT NOTE: Run `npm install` and `npm run build` to create the minified js and css file, its sourcemap files as well as the npm_dist/ folder and content!
193195

194196

195197
## License

assets/css/atcb.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Add-to-Calendar Button
44
* ++++++++++++++++++++++
55
*
6-
* Version: 1.4.1
6+
* Version: 1.4.2
77
* Creator: Jens Kuerschner (https://jenskuerschner.de)
88
* Project: https://github.com/jekuer/add-to-calendar-button
99
* License: MIT with “Commons Clause” License Condition v1.0

assets/css/atcb.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/atcb.min.css.map

Lines changed: 1 addition & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/atcb.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Add-to-Calendar Button
44
* ++++++++++++++++++++++
55
*/
6-
const atcbVersion = '1.4.1';
6+
const atcbVersion = '1.4.2';
77
/* Creator: Jens Kuerschner (https://jenskuerschner.de)
88
* Project: https://github.com/jekuer/add-to-calendar-button
99
* License: MIT with “Commons Clause” License Condition v1.0
@@ -488,7 +488,7 @@ function atcb_generate_ical(data) {
488488
"END:VEVENT",
489489
"END:VCALENDAR"
490490
];
491-
let dlurl = 'data:text/calendar;base64,'+btoa(ics_lines.join('\r\n'));
491+
let dlurl = 'data:text/calendar;base64,'+btoa(ics_lines.join('\r\n').replace(/[\u00A0-\u2666]/g, function(c) { return '&#' + c.charCodeAt(0) + ';'; })); // includes a fix to not throw an error with non-Latin1 characters. However, still needs improvement, since it shows up encoded in the iCal file.
492492
try {
493493
if (!window.ActiveXObject) {
494494
let save = document.createElement('a');
@@ -573,5 +573,7 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general') {
573573

574574

575575

576-
// START THE MAGIC AS SOON AS THE DOM HAS BEEN LOADED
577-
document.addEventListener('DOMContentLoaded', atcb_init, false);
576+
// START INIT
577+
document.addEventListener('DOMContentLoaded', atcb_init, false); // init the magic as soon as the DOM has been loaded
578+
//export { atcb_init }; // export statement - requires explicit init somewhere else. Remove the line above, if you want to use this one here
579+
// END INIT

assets/js/atcb.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)