Skip to content

Commit 2ee195a

Browse files
paulbertdogi
authored andcommitted
add mdwiki build scripts (#758)
1 parent 031e2bb commit 2ee195a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+7764
-14
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
node_modules/
2+
13
## =============================================================================
24
## !!! STOP. DO NOT MODIFY BELOW THIS LINE. !!!
35
## =============================================================================

Gruntfile.js

+275
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
var createIndex = function (grunt, taskname) {
2+
'use strict';
3+
var conf = grunt.config('index')[taskname],
4+
tmpl = grunt.file.read(conf.template);
5+
6+
// register the task name in global scope so we can access it in the .tmpl file
7+
grunt.config.set('currentTask', {name: taskname});
8+
9+
grunt.file.write(conf.dest, grunt.template.process(tmpl));
10+
grunt.log.writeln('Generated \'' + conf.dest + '\' from \'' + conf.template + '\'');
11+
};
12+
13+
/*global module:false*/
14+
module.exports = function(grunt) {
15+
'use strict';
16+
// Project configuration.
17+
18+
// Put files to be included in build here
19+
var ownJsFiles = [
20+
'js/marked.js',
21+
'js/init.js',
22+
'js/logging.js',
23+
'js/stage.js',
24+
'js/main.js',
25+
'js/util.js',
26+
'js/modules.js',
27+
'js/basic_skeleton.js',
28+
'js/bootstrap.js',
29+
'js/gimmicker.js',
30+
31+
// gimmicks
32+
'js/gimmicks/alerts.js',
33+
'js/gimmicks/colorbox.js',
34+
'js/gimmicks/carousel.js',
35+
'js/gimmicks/disqus.js',
36+
'js/gimmicks/facebooklike.js',
37+
'js/gimmicks/forkmeongithub.js',
38+
//'js/gimmicks/github_gist.js',
39+
'js/gimmicks/gist.js',
40+
'js/gimmicks/googlemaps.js',
41+
'js/gimmicks/highlight.js',
42+
'js/gimmicks/iframe.js',
43+
'js/gimmicks/math.js',
44+
// 'js/gimmicks/leaflet.js',
45+
'js/gimmicks/themechooser.js',
46+
'js/gimmicks/twitter.js',
47+
'js/gimmicks/youtube_embed.js',
48+
'js/gimmicks/chart.js',
49+
'js/gimmicks/yuml.js'
50+
],
51+
internalCssFiles = [
52+
'extlib/css/colorbox.css'
53+
],
54+
// ONLY PUT ALREADY MINIFIED FILES IN HERE!
55+
internalJsFiles = [
56+
'extlib/js/jquery.colorbox.min.js'
57+
],
58+
59+
// files that we inline in the fat release (basically everything)
60+
// ONLY PUT ALREADY MINIFIED FILES IN HERE!
61+
externalJsFiles = [
62+
'extlib/js/jquery-3.2.0.min.js',
63+
'extlib/js/bootstrap-3.0.0.min.js',
64+
// Highlight.js crashes when included inline. Included script tag in index.tmpl for usage.
65+
//'extlib/js/highlight-7.3.min.js'
66+
],
67+
externalCssFiles = [
68+
'extlib/css/highlight.github.css',
69+
'extlib/css/bootstrap-3.0.0.min.css',
70+
];
71+
72+
// Map across above directories to add mdwiki/ at start
73+
var addMdwikiFolder = function(fileRef) {
74+
if(fileRef.startsWith('mdwiki/')) {
75+
return fileRef;
76+
}
77+
return 'mdwiki/' + fileRef;
78+
}
79+
80+
grunt.initConfig({
81+
// Metadata.
82+
pkg: {
83+
name: 'MDwiki-OLE',
84+
version: '0.6.3'
85+
},
86+
87+
ownJsFiles: ownJsFiles.map(addMdwikiFolder),
88+
internalCssFiles: internalCssFiles.map(addMdwikiFolder),
89+
internalJsFiles: internalJsFiles.map(addMdwikiFolder),
90+
externalJsFiles: externalJsFiles.map(addMdwikiFolder),
91+
externalCssFiles: externalCssFiles.map(addMdwikiFolder),
92+
93+
// references we add in the slim release (stuff available on CDN locations)
94+
// Not used for open-learning-exchange, but left in as option
95+
externalJsRefs: [
96+
'ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js',
97+
'netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js',
98+
'yandex.st/highlightjs/7.3/highlight.min.js'
99+
],
100+
externalCssRefs: [
101+
'netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css',
102+
'yandex.st/highlightjs/7.3/styles/github.min.css'
103+
// 'www.3solarmasses.com/retriever-bootstrap/css/retriever.css'
104+
// '3solarmasses.com/corgi-bootstrap/css/corgi.css'
105+
],
106+
107+
concat: {
108+
options: {
109+
//banner: '<%= banner %>',
110+
stripBanners: true
111+
},
112+
dev: {
113+
src: '<%= ownJsFiles %>',
114+
dest: 'mdwiki/dist/<%= pkg.name %>.js'
115+
}
116+
},
117+
uglify: {
118+
options: {
119+
// banner: '<%= banner %>'
120+
},
121+
dist: {
122+
src: '<%= concat.dev.dest %>',
123+
dest: 'mdwiki/dist/<%= pkg.name %>.min.js'
124+
}
125+
},
126+
index: {
127+
fat: {
128+
template: 'mdwiki/index.tmpl',
129+
dest: 'mdwiki/dist/mdwiki.html'
130+
},
131+
slim: {
132+
template: 'mdwiki/index.tmpl',
133+
dest: 'mdwiki/dist/mdwiki-slim.html'
134+
},
135+
debug: {
136+
template: 'mdwiki/index.tmpl',
137+
dest: 'mdwiki/dist/mdwiki-debug.html'
138+
}
139+
},
140+
/* make it use .jshintrc */
141+
jshint: {
142+
options: {
143+
curly: false,
144+
eqeqeq: true,
145+
immed: true,
146+
latedef: true,
147+
newcap: true,
148+
noarg: true,
149+
sub: true,
150+
undef: true,
151+
unused: false,
152+
boss: true,
153+
eqnull: true,
154+
browser: true,
155+
globals: {
156+
jQuery: true,
157+
marked: true,
158+
google: true,
159+
hljs: true,
160+
/* leaflet.js*/
161+
L: true,
162+
console: true,
163+
Chart: true
164+
}
165+
},
166+
/*gruntfile: {
167+
src: 'Gruntfile.js'
168+
},*/
169+
js: {
170+
src: ['mdwiki/js/*.js', 'mdwiki/js/**/*.js', '!mdwiki/js/marked.js']
171+
}
172+
},
173+
lib_test: {
174+
src: ['mdwiki/lib/**/*.js', 'mdwiki/test/**/*.js']
175+
},
176+
copy: {
177+
release_fat: {
178+
expand: false,
179+
flatten: true,
180+
src: [ 'mdwiki/dist/mdwiki.html' ],
181+
dest: 'mdwiki/release/mdwiki-<%= grunt.config("pkg").version %>/mdwiki.html'
182+
},
183+
release_slim: {
184+
expand: false,
185+
flatten: true,
186+
src: [ 'mdwiki/dist/mdwiki-slim.html' ],
187+
dest: 'mdwiki/release/mdwiki-<%= grunt.config("pkg").version %>/mdwiki-slim.html'
188+
},
189+
release_debug: {
190+
expand: false,
191+
flatten: true,
192+
src: [ 'mdwiki/dist/mdwiki-debug.html' ],
193+
dest: 'mdwiki/release/mdwiki-<%= grunt.config("pkg").version %>/mdwiki-debug.html'
194+
},
195+
release_templates: {
196+
expand: true,
197+
flatten: true,
198+
src: [ 'mdwiki/release_templates/*' ],
199+
dest: 'mdwiki/release/mdwiki-<%= grunt.config("pkg").version %>/'
200+
},
201+
// Added for OLE. Release copies the fat version to index.html, devel does same with debug
202+
OLE_release: {
203+
expand: false,
204+
flatten: true,
205+
src: [ 'mdwiki/dist/mdwiki.html' ],
206+
dest: 'index.html'
207+
},
208+
OLE_devel: {
209+
expand: false,
210+
flatten: true,
211+
src: [ 'mdwiki/dist/mdwiki-debug.html' ],
212+
dest: 'index.html'
213+
}
214+
},
215+
shell: {
216+
zip_release: {
217+
options: {
218+
stdout: true
219+
},
220+
command: 'cd release && zip -r mdwiki-<%= grunt.config("pkg").version %>.zip mdwiki-<%= grunt.config("pkg").version %>'
221+
}
222+
},
223+
watch: {
224+
files: [
225+
'Gruntfile.js',
226+
'mdwiki/js/*.js',
227+
'mdwiki/js/**/*.js',
228+
'mdwiki/index.tmpl'
229+
],
230+
tasks: ['devel']
231+
},
232+
reload: {
233+
port: 35729,
234+
liveReload: {}
235+
}
236+
});
237+
238+
// These plugins provide necessary tasks.
239+
grunt.loadNpmTasks('grunt-contrib-jshint');
240+
grunt.loadNpmTasks('grunt-contrib-watch');
241+
grunt.loadNpmTasks('grunt-contrib-copy');
242+
grunt.loadNpmTasks('grunt-contrib-concat');
243+
grunt.loadNpmTasks('grunt-contrib-uglify');
244+
grunt.loadNpmTasks('grunt-shell');
245+
grunt.loadNpmTasks('grunt-reload');
246+
247+
grunt.registerTask('index_slim', 'Generate slim mdwiki.html, most scripts on CDN', function() {
248+
createIndex(grunt, 'slim');
249+
});
250+
251+
grunt.registerTask('index_fat', 'Generate mdwiki-fat.html, inline all scripts', function() {
252+
createIndex(grunt, 'fat');
253+
});
254+
grunt.registerTask('index_debug', 'Generate mdwiki-fat.html, inline all scripts', function() {
255+
createIndex(grunt, 'debug');
256+
});
257+
grunt.registerTask('release-slim',[ 'jshint', 'concat:dev', 'uglify:dist', 'index_slim' ]);
258+
grunt.registerTask('release-fat', [ 'jshint', 'concat:dev', 'uglify:dist', 'index_fat' ]);
259+
260+
/* Debug is basically the fat version but without any minifing */
261+
grunt.registerTask('release-debug', [ 'jshint', 'concat:dev', 'index_debug' ]);
262+
263+
grunt.registerTask('devel', [ 'release-debug','copy:OLE_devel', 'reload', 'watch' ]);
264+
265+
grunt.registerTask('release',[
266+
'release-slim', 'release-fat', 'release-debug',
267+
'copy:release_slim', 'copy:release_fat', 'copy:release_debug', 'copy:release_templates','copy:OLE_release',
268+
'shell:zip_release'
269+
]);
270+
// Default task.
271+
grunt.registerTask('default',
272+
[ 'release-slim', 'release-fat', 'release-debug' ]
273+
);
274+
275+
};

README.md

+7-14
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,12 @@ For Developers
118118

119119
You don't need to read below here or do anything at all if you're only interested creating your own wiki. This section is for developers or maintainers of this repository.
120120

121-
Update MDwiki
121+
Make changes to MDwiki
122122
-------------
123123

124-
> Current version: [0.6.2](http://git.io/HBH5Wg).
125-
126-
1. Go to https://github.com/Dynalon/mdwiki/releases/latest
127-
1. Click on the green button on that page to download the latest release
128-
1. Extract the contents of the archive file
129-
1. Copy `mdwiki-slim.html` file from the extracted files on this repository by renaming, thus overriding `index.html`
130-
1. Modify `index.html`to show title page on browser tab. Find this code: ``` function(a){function b(){var b;if(a.md.config.title&&a("title").text(a.md.config.title),b=a("#md-content h1").eq(0),a.trim(b.toptext()).length>0){a("#md-title").prepend(b);{b.toptext()}}else a("#md-title").remove()}```
131-
,then add `a("title").text(b.text());` before `a("#md-title").prepend(b);`
132-
1. Insert the code ```<script type='text/javascript'> $(document).ready(function() {$( "body" ).on( "click", "a", function() {$("a[href^='http://']").each(function(){if(this.href.indexOf(location.hostname) == -1) {$(this).attr('target', '_blank'); } }); $("a[href^='https://']").each(function(){if(this.href.indexOf(location.hostname) == -1) {$(this).attr('target', '_blank'); } }); }); }); </script>``` into tag `<head>...</head>` of `index.html` (should be at the end of the tag) to open an external link with new tab.
133-
1. Update the version information above
134-
1. Commit and push your changes
135-
136-
You can now delete any files downloaded previously, if you want to.
124+
1. If you haven't already, [install Node](https://docs.npmjs.com/getting-started/installing-node).
125+
2. Open a command prompt/shell/git bash and navigate to your repo's directory.
126+
3. Run `npm install` to install mdwiki dependencies.
127+
4. For development, you can run `./node_modules/.bin/grunt devel` or `grunt devel` if you have grunt installed globally. This will start grunt watching the index.tmpl and *.js files for changes, which you can view at `localhost:35729`. The index.html file that it builds is the debug version of the html with the full js files.
128+
5. As a note, the index.tmpl is where our custom CSS can be found. Please only add CSS within the comment denoted section.
129+
6. Once you have completed your changes, run `./node_modules/.bin/grunt release` to build an index.html with minified js.

mdwiki/.editorconfig

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*.js]
5+
indent_style = space
6+
indent_size = 4
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true

mdwiki/.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
node_modules
2+
bower_components/
3+
node_modules/
4+
dist/
5+
release/
6+
.tmp
7+
app/components
8+
md/
9+
.DS_Store
10+
.AppleDouble

mdwiki/.jshintrc

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"node": true,
3+
"browser": true,
4+
"es5": true,
5+
"esnext": true,
6+
"bitwise": true,
7+
"camelcase": false,
8+
"curly": false,
9+
"eqeqeq": true,
10+
"immed": true,
11+
"indent": 4,
12+
"latedef": true,
13+
"newcap": true,
14+
"noarg": true,
15+
"quotmark": "single",
16+
"regexp": true,
17+
"undef": true,
18+
"unused": false,
19+
"strict": true,
20+
"trailing": true,
21+
"smarttabs": true,
22+
"globals": {
23+
"marked": true,
24+
"jQuery": true,
25+
"console": true,
26+
"google": true,
27+
"hljs": true,
28+
"L": true
29+
}
30+
}

mdwiki/.travis.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: node_js
2+
env:
3+
global:
4+
secure: fdhQHNFGs/fvXLZ79oF4w2Csps1lIrJHyMq+NPoM9oYumDgtjNOG3FUl0rswWzRdzURbI4NrwM9ViCKNmb8axFavwDjnyD9/Ad4URPaDvLg/tQA6uZePOh7IMnHh8PG6FIIe/Hu5vRNjWpxYoocx9u/GZlDDpndwy4d4802cHpg=
5+
before_script:
6+
- npm install grunt-cli
7+
script:
8+
- grunt release-fat release-slim release-debug
9+
10+
after_success: ./upload-build.sh

0 commit comments

Comments
 (0)