-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathbuild-doc.js
More file actions
1217 lines (1146 loc) · 52.9 KB
/
Copy pathbuild-doc.js
File metadata and controls
1217 lines (1146 loc) · 52.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Transform Markdown documentation to HTML
*/
var gulp = require('gulp');
var MarkdownIt = require('markdown-it');
var mdToc = require('markdown-it-toc-and-anchor').default;
var mdEmoji = require('markdown-it-emoji');
var flatmap = require('gulp-flatmap');
var insert = require('gulp-insert');
var path = require('path');
var gulpMarkdownIt = require('gulp-markdown-it-adapter');
var highlightJs = require('highlightjs');
var Prism = require('prismjs');
var hbs = require('handlebars');
var gulpHandlebars = require('gulp-handlebars-html')(hbs);
var fs = require('fs');
var rename = require('gulp-rename');
var replace = require('gulp-replace');
var concat = require('gulp-concat');
var revReplace = require('gulp-rev-replace');
var swagger = require('gulp-swagger');
var jsonTransform = require('gulp-json-transform');
var _ = require('lodash');
var titleDescription = require('../title-description.json')
const loadLanguages = require('prismjs/components/');
loadLanguages(['php','javascript','python', 'java', 'shell']);
function getTocMarkdown(isOnePage, pages, currentPage, baseUrl) {
if(isOnePage){
return "\n\n:::: toc\n@[toc]\n\n::::\n\n";
} else {
return "\n\n:::: toc\n\n" + Object.keys(pages).map(function (page) {
if (page === currentPage) {
return '::: preToc ' + pages[page] + "\n:::\n@[toc]\n:::postToc\n:::";
} else {
return '::: tocLink [' + pages[page]+ '](' + baseUrl + '/' + page.replace(/\.md$/, '.html') + ")\n:::";
}
}).join("\n") + "\n\n::::\n\n";
}
}
function highlight(str, lang) {
if (lang && highlightJs.getLanguage(lang)) {
try {
return '<pre class="hljs"><code>' +
highlightJs.highlight(lang, str, true).value +
'</code></pre>';
} catch (__) {}
}
return '<pre class="hljs"><code>' + str + '</code></pre>';
}
function highlightGt(str, lang) {
if (lang && lang in Prism.languages) {
try {
return Prism.highlight(str, Prism.languages[lang], lang);
} catch (__) {}
}
return '<pre><code class="language-markup">' + str + '</code></pre>';
}
function imageTokenOverride(tokens, idx, options, env, self) {
return '<img class="img-responsive in-article" alt="'+ tokens[idx].content +'" src="'+ tokens[idx].attrs[0][1] + '"/>';
}
var optionsMd = {
html: true,
xhtmlOut: true,
typographer: false,
linkify: false,
breaks: false,
highlight: highlight
};
var optionsMdGt = {
html: true,
xhtmlOut: true,
typographer: false,
linkify: false,
breaks: false,
highlight: highlightGt
};
var md = new MarkdownIt('default', optionsMd);
var mdGt = new MarkdownIt('default', optionsMdGt);
var glogalOptionsToc = {
toc: true,
tocFirstLevel: 2,
tocLastLevel: 3,
anchorLink: true,
anchorLinkSpace: false,
anchorLinkBefore: true,
tocClassName: 'nav'
};
initMd(md);
initMd(mdGt);
function initMd(markdown) {
markdown.renderer.rules['image'] = imageTokenOverride;
markdown.renderer.rules.table_open = function(tokens, idx) {
return '<table class="table">';
};
markdown.renderer.rules.heading_open = function(tokens, idx) {
return '<a class="anchor" id="' + tokens[idx].attrs[0][1] + '"></a>'+
'<'+tokens[idx].tag+' title-id="' + tokens[idx].attrs[0][1] + '">';
};
markdown.use(mdEmoji);
markdown.use(mdToc, glogalOptionsToc);
markdown.use(require('markdown-it-container'), 'danger', {
validate: function(params) {
return params.trim().match(/^danger(.*)$/);
},
render: function (tokens, idx) {
return (tokens[idx].nesting === 1) ? '<div class="alert alert-danger">' : '</div>\n';
}
});
markdown.use(require('markdown-it-container'), 'warning', {
validate: function(params) {
return params.trim().match(/^warning(.*)$/);
},
render: function (tokens, idx) {
return (tokens[idx].nesting === 1) ? '<div class="alert alert-warning">' : '</div>\n';
}
});
markdown.use(require('markdown-it-container'), 'info', {
validate: function(params) {
return params.trim().match(/^info(.*)$/);
},
render: function (tokens, idx) {
return (tokens[idx].nesting === 1) ? '<div class="alert alert-info">' : '</div>\n';
}
});
markdown.use(require('markdown-it-container'), 'tips', {
validate: function(params) {
return params.trim().match(/^tips(.*)$/);
},
render: function (tokens, idx) {
return (tokens[idx].nesting === 1) ? '<div class="alert alert-tips">' : '</div>\n';
}
});
markdown.use(require('markdown-it-container'), 'availability', {
validate: function(params) {
return params.trim().match(/^availability(.*)$/);
},
render: function (tokens, idx) {
var versionsAndEditions = tokens[idx].info.trim().match(/^availability\sversions=(.*)\seditions=(.*)$/);
var html = '';
if(tokens[idx].nesting === 1) {
var versions = versionsAndEditions[1].split(',');
html += _.reduce(versions, function(res, version) {
return res + ' <span class="label label-version">' + version + '</span>';
}, '<p><em class="small text-primary">Available in the PIM versions:</em>');
var editions = versionsAndEditions[2].split(',');
html += _.reduce(editions, function(res, edition) {
return res + ' <span class="label label-info">' + edition + '</span>';
}, '<em class="small text-primary"> | Available in the PIM editions:</em>');
} else {
html = '</p>';
}
return html;
}
});
markdown.use(require('markdown-it-container'), 'php-client-availability', {
validate: function(params) {
return params.trim().match(/^php-client-availability(.*)$/);
},
render: function (tokens, idx) {
let html = '';
if(tokens[idx].nesting === 1) {
const matchedAllVersions = tokens[idx].info.trim().match(/^php-client-availability.*all-versions(\s|$)/);
if (matchedAllVersions !== null) {
html += '<p><em class="small text-primary">Available in all client versions</em>';
}
const matchedVersions = tokens[idx].info.trim().match(/^php-client-availability.*versions=(.*?)(\s|$)/);
if (matchedVersions !== null) {
const versions = matchedVersions[1].split(',');
html += _.reduce(versions, function(res, version) {
return res + ' <span class="label label-version">' + version + '</span>';
}, '<p><em class="small text-primary">Available since client version:</em>');
}
const matchedEE = tokens[idx].info.trim().match(/^php-client-availability.*ee-only(\s|$)/);
if (matchedEE !== null) {
html += '<em class="small text-primary"> | Only available for PIM </em><span class="label label-info">EE</span>'
}
} else {
html = '</p>';
}
return html;
}
});
markdown.use(require('markdown-it-container'), 'version-screenshots', {
validate: function(params) {
return params.trim().match(/^version-screenshots(.*)$/);
},
render: function (tokens, idx) {
var id = tokens[idx].info.trim().match(/^version-screenshots\sid="(.*)"\s2\.x.*\s1\.7.*$/);
var source_v2x = tokens[idx].info.trim().match(/^version-screenshots\sid=".*"\s2\.x(.*)\s1\.7.*$/);
var source_v17 = tokens[idx].info.trim().match(/^version-screenshots\sid=".*"\s2\.x.*\s1\.7(.*)$/);
return (tokens[idx].nesting === 1) ? '<div>' +
'<ul class="nav nav-tabs nav-tabs-versions" role="tablist">' +
'<li role="presentation" class="active"><a href="#v2_' + id[1] + '" aria-controls="v2_' + id[1] + '" role="tab" data-toggle="tab">Since v2</a></li>' +
'<li role="presentation"><a href="#v17_' + id[1] + '" aria-controls="v17_' + id[1] + '" role="tab" data-toggle="tab">v1.7</a></li>' +
'</ul>' +
'<div class="panel panel-default">' +
'<div class="panel-body">' +
'<div class="row tab-content">'+
'<div role="tabpanel" class="col-xs-12 tab-pane active" id="v2_' + id[1] + '">' + markdown.render(source_v2x[1]) + '</div>' +
'<div role="tabpanel" class="col-xs-12 tab-pane" id="v17_' + id[1] + '">' + markdown.render(source_v17[1]) + '</div>'
: '</div>\n</div>\n</div>\n</div>\n';
}
});
markdown.use(require('markdown-it-container'), 'toc', {
validate: function(params) {
return params.trim().match(/^toc$/);
},
render: function (tokens, idx) {
return (tokens[idx].nesting === 1) ? '<div id="navbar" class="col-sm-3 hidden-xs sticky">' +
'<nav role="tablist" id="navbar-nav"><ul class="nav nav-stacked" style="counter-increment: step-counter;"><p class="pre-nav">Summary</p>' :
"</ul></nav></div>\n";
}
});
markdown.use(require('markdown-it-container'), 'preToc', {
validate: function(params) {
return params.trim().match(/^preToc .*/);
},
render: function (tokens, idx) {
var text = tokens[idx].info.trim().match(/^preToc (.*)$/);
return (tokens[idx].nesting === 1) ? '<li class="active"> <a href="#">' + text[1] + '</a>': '';
}
});
markdown.use(require('markdown-it-container'), 'postToc', {
validate: function(params) {
return params.trim().match(/^postToc$/);
},
render: function (tokens, idx) {
return (tokens[idx].nesting === 1) ? '</li>' : '';
}
});
markdown.use(require('markdown-it-container'), 'mainContent', {
validate: function(params) {
return params.trim().match(/^mainContent$/);
},
render: function (tokens, idx) {
return (tokens[idx].nesting === 1) ? '<div class="col-xs-12 col-sm-offset-1 col-sm-8">' : '</div>';
}
});
markdown.use(require('markdown-it-container'), 'tocLink', {
validate: function(params) {
return params.trim().match(/^tocLink\s+(.*)$/);
},
render: function (tokens, idx) {
var linkTitle = tokens[idx].info.trim().match(/^tocLink.*\[(.*)\]\(.*\)$/);
var link = tokens[idx].info.trim().match(/^tocLink.*\((.*)\)$/);
return (tokens[idx].nesting === 1) ? '<li><a href="' + markdown.utils.escapeHtml(link[1]) + '">' + linkTitle[1] + '</a></li>' : '';
}
});
markdown.use(require('markdown-it-container'), 'panel-link', {
validate: function(params) {
return params.trim().match(/^panel-link\s+(.*)$/);
},
render: function (tokens, idx) {
var text = tokens[idx].info.trim().match(/^panel-link\s+(.*)\[.*\].*$/);
var linkTitle = tokens[idx].info.trim().match(/^panel-link\s+.*\[(.*)\].*$/);
var link = tokens[idx].info.trim().match(/^panel-link\s+.*\((.*)\)$/);
if (tokens[idx].nesting === 1) {
// opening tag
return '<div class="row" style="margin-top: 80px;"><div class="col-sm-offset-3 col-sm-6">' +
'<div class="panel panel-default panel-btn">'+
'<a href="' + markdown.utils.escapeHtml(link[1]) + '">' +
'<div class="panel-body">' +
'<div class="panel-btn-big">'+ markdown.utils.escapeHtml(text[1]) + '</div>'+
'<p class="text-center">'+ markdown.utils.escapeHtml(linkTitle[1]) + '</p>';
} else {
// closing tag
return '</div></a></div></div></div>\n';
}
}
});
markdown.use(require("markdown-it-codetabs"));
markdown.use(require("markdown-it-include"));
}
function getPageTitle(fileName, defaultTitle = '') {
let title = defaultTitle;
titleDescription.forEach(function (element) {
if(fileName
.replace('/opt/workdir/content/', '')
.replace('/opt/workdir/tmp/', '')
.replace('.md', '') === element.content_dir) {
title = element.title;
}
});
return title;
}
function getPageDescription(fileName, defaultDescription = 'Description') {
let description = defaultDescription;
titleDescription.forEach(function (element) {
if(fileName
.replace('/opt/workdir/content/', '')
.replace('/opt/workdir/tmp/', '')
.replace('.md', '') === element.content_dir) {
description = element.description;
}
});
return description;
}
gulp.task('build-getting-started', ['clean-dist','less'], function () {
const synchronizePimProductsName = 'synchronize-pim-products';
var pages = {
'your-first-tutorial-4x': {
gettingStartedName: 'your-first-tutorial',
pimVersion: 'v4 / v5 / v6 / v7 / SaaS',
title: 'Your very first tutorial',
image: 'illustrations/illus--v4.svg',
files: {
'welcome.md': 'Welcome',
'step-1.md': 'Step 1 | Create a Connection',
'step-2.md': 'Step 2 | Set up Postman',
'step-3.md': 'Step 3 | Make the REST API request'
},
availability: {
serenity: "4x",
v7: "4x",
v6: "4x",
v5: "4x",
v4: "4x",
old: "old"
}
},
'your-first-tutorial-old': {
gettingStartedName: 'your-first-tutorial',
pimVersion: 'v1.7 / v2 / v3',
title: 'Your very first tutorial',
image: 'illustrations/illus--old-versions.svg',
files: {
'welcome.md': 'Welcome',
'step-1.md': 'Step 1 | Generate the credentials',
'step-2.md': 'Step 2 | Set up Postman',
'step-3.md': 'Step 3 | Make the REST API request'
},
availability: {
serenity: "4x",
v7: "4x",
v6: "4x",
v5: "4x",
v4: "4x",
old: "old"
}
},
'connect-the-pim-4x': {
gettingStartedName: 'connect-the-pim',
pimVersion: 'v4 / v5 / v6 / v7 / SaaS',
title: 'The "Connect the PIM" tutorial',
image: 'illustrations/illus--v4.svg',
files: {
'welcome.md': 'Welcome',
'step-1.md': 'Step 1 | Create a Connection',
'step-2.md': 'Step 2 | Cook your connector',
'step-3.md': 'Step 3 | Identify your connector in the PIM'
},
availability: {
serenity: "4x",
v7: "4x",
v6: "4x",
v5: "4x",
v4: "4x",
old: "old"
}
},
'connect-the-pim-old': {
gettingStartedName: 'connect-the-pim',
pimVersion: 'v1.7 / v2 / v3',
title: 'The "Connect the PIM" tutorial',
image: 'illustrations/illus--v4.svg',
files: {
'welcome.md': 'Welcome',
'step-1.md': 'Step 1 | Cook your connector',
'step-2.md': 'Step 2 | Generate the credentials',
'step-3.md': 'Step 3 | Configure your connector'
},
availability: {
serenity: "4x",
v7: "4x",
v6: "4x",
v5: "4x",
v4: "4x",
old: "old"
}
},
'quick-start-my-first-webhook-5x': {
gettingStartedName: 'quick-start-my-first-webhook',
pimVersion: 'v5 / v6 / v7/ SaaS',
title: 'Quick start my first webhook',
files: {
'welcome.md': 'Welcome',
'step-1.md': 'Step 1 | Receive my first set of data',
'step-2.md': 'Step 2 | Create your own Symfony app to display event subscriptions data'
},
availability: {
serenity: "5x",
v7: "5x",
v6: "5x",
v5: "5x"
}
},
'events-api-best-practices-5x': {
gettingStartedName: 'events-api-best-practices',
pimVersion: 'v5 / v6 / v7 / SaaS',
title: 'Events API best practices',
files: {
'welcome.md': 'Best practices',
},
availability: {
serenity: "5x",
v7: "5x",
v6: "5x",
v5: "5x"
}
},
'synchronize-pim-products-6x': {
gettingStartedName: synchronizePimProductsName,
pimVersion: 'v6 / v7 / SaaS',
title: 'Synchronize PIM products with your App',
files: {
'welcome.md': 'Welcome',
'step-0.md': 'Discover the PIM objects relationship schema',
'step-1.md': 'Synchronize PIM structure',
'step-2.md': 'Synchronize Catalog structure: families and attributes',
'step-3.md': 'Synchronize Catalog structure: categories',
'step-4.md': 'Synchronize Products and product models',
'step-5.md': 'Synchronize Reference entities',
'step-6.md': 'Synchronize Assets'
},
availability: {
serenity: "6x",
v7: "6x",
v6: "6x"
}
},
'from-identifiers-to-uuid-7x': {
gettingStartedName: 'from-identifiers-to-uuid',
pimVersion: 'v7 / SaaS',
title: 'From product identifiers to UUID',
files: {
'welcome.md': 'Guide',
},
availability: {
serenity: "7x",
v7: "7x",
}
},
};
var isOnePage = false;
return gulp.src('content/getting-started/**/*.md')
.pipe(flatmap(function(stream, file){
return gulp.src('content/getting-started/**/*.md')
.pipe(insert.wrap("::::: mainContent\n", "\n:::::"))
.pipe(insert.prepend(getTocMarkdown(isOnePage, pages[path.basename(path.dirname(file.path))].files, path.basename(file.path), '/getting-started/' + path.basename(path.dirname(file.path))) + "\n"))
.pipe(gulpMarkdownIt(md))
.pipe(gulp.dest('tmp/getting-started/'))
.on('end', function () {
const gettingStartedName = pages[path.basename(path.dirname(file.path))].gettingStartedName;
return gulp.src('src/partials/getting-started.handlebars')
.pipe(gulpHandlebars({
active_api_resources: gettingStartedName !== synchronizePimProductsName,
active_apps: gettingStartedName === synchronizePimProductsName,
title: pages[path.basename(path.dirname(file.path))].title,
description: getPageDescription(file.path),
image: pages[path.basename(path.dirname(file.path))].image,
gettingStartedName: gettingStartedName,
pimVersion: pages[path.basename(path.dirname(file.path))].pimVersion,
availability: pages[path.basename(path.dirname(file.path))].availability,
mainContent: fs.readFileSync('tmp/getting-started/' + path.basename(path.dirname(file.path)) + '/' + path.basename(file.path).replace(/\.md/, '.html'))
}, {
partialsDirectory: ['./src/partials']
}))
.pipe(rename(path.basename(file.path).replace(/\.md/, '.html')))
.pipe(revReplace({manifest: gulp.src("./tmp/rev/rev-manifest.json")}))
.pipe(gulp.dest('./dist/getting-started/' + path.basename(path.dirname(file.path))));
})
}));
}
);
gulp.task('build-guides', ['clean-dist','less'], function () {
var pages = {
'dam-connection': {
title: 'The complete guide to connect a DAM to your PIM',
files: {
'introduction.md': 'Introduction',
'pre-requisites.md': 'Structure your DAM and your PIM',
'technical-stack.md': 'Define your technical stack',
'synchronize-assets.md': 'Dive into the synchronisation',
'glossary.md': 'Glossary'
}
},
'ecommerce-connection': {
title: 'The complete guide to connect Akeneo PIM to your eCommerce solution',
files: {
'introduction.md': 'Introduction',
'step0-who-is-your-app-intended-for.md': 'Who is your App intended for?',
'step1-who-does-what.md': 'Who does what?',
'step2-understand-akeneo-pim.md': 'Understand Akeneo PIM data',
'step3-reconcile-PIM-data-with-eCommerce-data.md': 'Reconcile PIM data with eCommerce data',
'step4-define-your-first-scope.md': 'Define the first scope of your App'
}
},
'translation-connection': {
title: 'The complete guide to connect Akeneo PIM to your online translation solution',
files: {
'introduction.md': 'Introduction',
'step1-who-is-your-app-intended-for.md': 'Who is your App intended for?',
'step2-understand-akeneo-pim.md': 'Understand Akeneo PIM data',
'step3-how-to-build-your-app.md': 'How to build your App?',
'step4-known-limits.md': 'Known limits'
}
},
'erp-connection': {
title: 'The complete guide to connect your ERP solution to Akeneo PIM',
files: {
'introduction.md': 'Introduction',
'step1-who-is-your-app-intended-for.md': 'Who is your App intended for?',
'step2-analyze-erp-data.md': 'Analyze your ERP data',
'step3-understand-akeneo-pim.md': 'Understand Akeneo PIM',
'step4-how-to-build-your-app.md': 'How to build your App?'
}
},
'syndication-connection': {
title: 'The complete guide to connect Akeneo PIM to your syndication solution',
files: {
'introduction.md': 'Introduction',
'step0-who-is-your-app-intended-for.md': 'Who is your App intended for?',
'step1-who-does-what.md': 'Who does what?',
'step2-understand-akeneo-pim.md': 'Understand Akeneo PIM data',
'step3-define-your-first-scope.md': 'How to build your App?'
}
},
'print-connection': {
title: 'A high-level guide to connecting Akeneo PIM to your print solution',
files: {
'introduction.md': 'Introduction',
'step0-who-is-your-app-intended-for.md': 'Who is your App intended for?',
'step1-who-does-what.md': 'Who does what?',
'step2-understand-akeneo-pim.md': 'Understand Akeneo PIM data',
'step3-reconcile-PIM-data-with-print-features.md': 'Reconcile PIM data with print capabilities',
'step4-define-your-first-scope.md': 'How to build your App'
}
}
};
var isOnePage = false;
return gulp.src('content/guides/**/*.md')
.pipe(flatmap(function(stream, file){
return gulp.src('content/guides/**/*.md')
.pipe(insert.wrap("::::: mainContent\n", "\n:::::"))
.pipe(insert.prepend(getTocMarkdown(isOnePage, pages[path.basename(path.dirname(file.path))].files, path.basename(file.path), '/guides/' + path.basename(path.dirname(file.path))) + "\n"))
.pipe(gulpMarkdownIt(md))
.pipe(gulp.dest('tmp/guides/'))
.on('end', function () {
return gulp.src('src/partials/documentation.handlebars')
.pipe(gulpHandlebars({
active_apps: true,
title: pages[path.basename(path.dirname(file.path))].title,
description: getPageDescription(file.path),
mainContent: fs.readFileSync('tmp/guides/' + path.basename(path.dirname(file.path)) + '/' + path.basename(file.path).replace(/\.md/, '.html'))
}, {
partialsDirectory: ['./src/partials']
}))
.pipe(rename(path.basename(file.path).replace(/\.md/, '.html')))
.pipe(revReplace({manifest: gulp.src("./tmp/rev/rev-manifest.json")}))
.pipe(gulp.dest('./dist/guides/' + path.basename(path.dirname(file.path))));
})
}));
}
);
gulp.task('build-rest-api', ['clean-dist','less'], function () {
var pages = {
'why-the-api.md': "Why the REST API?",
'overview.md': 'Overview',
'authentication.md': 'Authentication',
'permissions.md': 'Permissions',
'responses.md': 'Response codes',
'pagination.md': 'Pagination',
'update.md': 'Update behavior',
'filter.md': 'Filters',
'troubleshooting.md': 'Troubleshooting guide'
};
var isOnePage = false;
return gulp.src('content/rest-api/*.md')
.pipe(flatmap(function(stream, file){
return gulp.src('content/rest-api/*.md')
.pipe(insert.wrap("::::: mainContent\n", "\n:::::"))
.pipe(insert.prepend(getTocMarkdown(isOnePage, pages, path.basename(file.path), '/documentation') + "\n"))
.pipe(gulpMarkdownIt(md))
.pipe(gulp.dest('tmp/documentation/'))
.on('end', function () {
return gulp.src('src/partials/documentation.handlebars')
.pipe(gulpHandlebars({
active_api_resources: true,
title: 'The REST API basics',
description: getPageDescription(file.path),
mainContent: fs.readFileSync('tmp/documentation/' + path.basename(file.path).replace(/\.md/, '.html'))
}, {
partialsDirectory: ['./src/partials']
}))
.pipe(rename(path.basename(file.path).replace(/\.md/, '.html')))
.pipe(revReplace({manifest: gulp.src("./tmp/rev/rev-manifest.json")}))
.pipe(gulp.dest('./dist/documentation'));
})
}));
}
);
gulp.task('build-events-api', ['clean-dist','less'], function () {
var pages = {
'overview.md': 'Overview',
'subscription.md': 'Subscribe and receive events',
'security.md': 'Security',
'limits-and-scalability.md': 'Limits and scalibility',
'more-about-events.md': 'More about events'
};
var isOnePage = false;
return gulp.src('content/events-api/*.md')
.pipe(flatmap(function(stream, file){
return gulp.src('content/events-api/*.md')
.pipe(insert.wrap("::::: mainContent\n", "\n:::::"))
.pipe(insert.prepend(getTocMarkdown(isOnePage, pages, path.basename(file.path), '/events-documentation') + "\n"))
.pipe(gulpMarkdownIt(md))
.pipe(gulp.dest('tmp/events-documentation/'))
.on('end', function () {
return gulp.src('src/partials/events-documentation.handlebars')
.pipe(gulpHandlebars({
active_api_resources: true,
title: 'The Events API basics',
description: getPageDescription(file.path),
mainContent: fs.readFileSync('tmp/events-documentation/' + path.basename(file.path).replace(/\.md/, '.html'))
}, {
partialsDirectory: ['./src/partials']
}))
.pipe(rename(path.basename(file.path).replace(/\.md/, '.html')))
.pipe(revReplace({manifest: gulp.src("./tmp/rev/rev-manifest.json")}))
.pipe(gulp.dest('./dist/events-documentation'));
})
}));
}
);
gulp.task('build-app-developer-tools', ['clean-dist','less'], function () {
var pages = {
'homepage.md': 'Start building your App',
'overview.md': 'Overview',
'authentication-and-authorization.md': 'Authentication and authorization',
'catalogs.md': 'Catalogs for Apps <span class="label label-beta">Beta</span>',
'app-developer-tools.md': 'Developer tools',
'app-concepts-and-use-cases.md': 'App concepts and use cases',
'create-custom-app.md': 'Custom apps'
};
const startApp = {
'title': 'Start Apps',
'badge_name' : 'New',
'content': 'Starter for bootstraping your first Akeneo App quickly.',
'image': 'apps/dev-tools-langages.svg',
'rows': [
{
'image': 'icons/icon--github.png',
'content': 'Github repository:',
'breakline': true,
'link': 'https://github.com/akeneo/sample-apps',
'link_content': 'akeneo/sample-apps',
}
],
'author': 'By Akeneo'
};
const apiTools = [
{
'title': 'Postman collection',
'badge_image' : 'apps/dev-tools-postman.svg',
'content': 'Test Akeneo APIs right away with our Postman collection.',
'rows': [
{
'image': 'apps/dev-tools-download.svg',
'link': '/files/Akeneo PIM API.postman_collection.json',
'link_content': 'Download',
'download': true,
},
{
'image': 'apps/dev-tools-akeneo.svg',
'breakline': true,
'content': 'Documentation:',
'link': '/getting-started/your-first-tutorial-4x/step-2.html',
'link_content': 'Importing data into Postman',
},
],
'author': 'By Akeneo'
},
{
'title': 'PHP API client',
'content': 'The PHP client eases the usage of the REST API in your PHP projects when building extensions and/or tools for your PIM.',
'rows': [
{
'image': 'icons/icon--github.png',
'content': 'Github repository:',
'breakline': true,
'link': 'https://github.com/akeneo/api-php-client',
'link_content': 'akeneo/api-php-client',
},
{
'image': 'apps/dev-tools-akeneo.svg',
'content': 'Documentation:',
'link': '/php-client/introduction.html',
'link_content': 'PHP API client',
},
],
'author': 'By Akeneo'
},
];
const app = {
'title': 'Demo App',
'content': 'Our official and already-in-production ' +
'Demo App will help you to understand ' +
'how to use Akeneo App features.',
'image': 'apps/dev-tools-php.svg',
'rows': [
{
'image': 'icons/icon--github.png',
'content': 'Github repository:',
'breakline': true,
'link': 'https://github.com/akeneo/demo-app',
'link_content': 'akeneo/demo-app',
}
],
'author': 'By Akeneo'
};
var isOnePage = false;
return gulp.src(['content/apps/app-developer-tools.md'])
.pipe(flatmap(function (stream, file) {
return gulp.src('content/apps/app-developer-tools.md')
.pipe(insert.wrap("::::: mainContent\n", "\n:::::"))
.pipe(insert.prepend(getTocMarkdown(isOnePage, pages, path.basename(file.path), '/apps') + "\n"))
.pipe(gulpMarkdownIt(md))
.pipe(gulp.dest('tmp/apps/'))
.on('end', function () {
return gulp.src('src/partials/apps-developer-tools.handlebars')
.pipe(gulpHandlebars({
active_apps: true,
startApp : startApp,
apiTools : apiTools,
app : app,
mainContent: fs.readFileSync('tmp/apps/' + path.basename(file.path).replace(/\.md/, '.html')),
title: getPageTitle(file.path),
description: getPageDescription(file.path),
}, {
partialsDirectory: ['./src/partials']
}))
.pipe(rename(path.basename(file.path).replace(/\.md/, '.html')))
.pipe(revReplace({manifest: gulp.src("./tmp/rev/rev-manifest.json")}))
.pipe(gulp.dest('./dist/apps'));
})
}));
}
);
gulp.task('build-apps', ['clean-dist','less'], function () {
var pages = {
'homepage.md': 'Start building your App',
'overview.md': 'Overview',
'authentication-and-authorization.md': 'Authentication and authorization',
'catalogs.md': 'Catalogs for Apps <span class="label label-beta">Beta</span>',
'app-developer-tools.md': 'Developer tools',
'app-concepts-and-use-cases.md': 'App concepts and use cases',
'create-custom-app.md': 'Custom apps'
};
var isOnePage = false;
return gulp.src(['content/apps/*.md', '!content/apps/app-developer-tools.md'])
.pipe(flatmap(function(stream, file){
return gulp.src(['content/apps/*.md'])
.pipe(insert.wrap("::::: mainContent\n", "\n:::::"))
.pipe(insert.prepend(getTocMarkdown(isOnePage, pages, path.basename(file.path), '/apps') + "\n"))
.pipe(gulpMarkdownIt(md))
.pipe(gulp.dest('tmp/apps/'))
.on('end', function () {
return gulp.src('src/partials/apps.handlebars')
.pipe(gulpHandlebars({
active_apps: true,
title: getPageTitle(file.path, 'Apps'),
description: getPageDescription(file.path),
mainContent: fs.readFileSync('tmp/apps/' + path.basename(file.path).replace(/\.md/, '.html'))
}, {
partialsDirectory: ['./src/partials']
}))
.pipe(rename(path.basename(file.path).replace(/\.md/, '.html')))
.pipe(revReplace({manifest: gulp.src("./tmp/rev/rev-manifest.json")}))
.pipe(gulp.dest('./dist/apps'));
})
}));
}
);
gulp.task('build-app-portal', ['clean-dist','less'], function () {
var pages = {
'get-started.md': 'Get started',
'manage-your-team.md': 'Manage your team',
'create-app-record.md': 'Create an app record',
'manage-app-information.md': 'Manage app information',
'manage-app-notifications.md': 'Manage your app notifications',
'manage-app-availability.md': 'Manage your app\'s availability',
'publish-your-app.md': 'App Publication Requirements',
'certify-your-app.md': 'Certify your app',
'measure-app-performance.md': 'Measure app performance'
};
var isOnePage = false;
return gulp.src(['content/app-portal/*.md'])
.pipe(flatmap(function(stream, file){
return gulp.src(['content/app-portal/*.md'])
.pipe(insert.wrap("::::: mainContent\n", "\n:::::"))
.pipe(insert.prepend(getTocMarkdown(isOnePage, pages, path.basename(file.path), '/app-portal') + "\n"))
.pipe(gulpMarkdownIt(md))
.pipe(gulp.dest('tmp/app-portal/'))
.on('end', function () {
return gulp.src('src/partials/app-portal.handlebars')
.pipe(gulpHandlebars({
active_apps_portal: true,
title: getPageTitle(file.path, 'App portal'),
description: getPageDescription(file.path),
mainContent: fs.readFileSync('tmp/app-portal/' + path.basename(file.path).replace(/\.md/, '.html'))
}, {
partialsDirectory: ['./src/partials']
}))
.pipe(rename(path.basename(file.path).replace(/\.md/, '.html')))
.pipe(revReplace({manifest: gulp.src("./tmp/rev/rev-manifest.json")}))
.pipe(gulp.dest('./dist/app-portal'));
})
}));
}
);
gulp.task('build-redirections', [
'to-get-your-app-token-redirection',
'to-apps-homepage',
'to-app-concepts-and-use-cases',
]);
gulp.task('to-get-your-app-token-redirection', ['clean-dist','less'], function () {
return gulp.src('content/redirections/to-get-your-app-token.html')
.pipe(rename('apps-getting-started.html'))
.pipe(gulp.dest('./dist/apps'))
});
gulp.task('to-apps-homepage', ['clean-dist', 'less'], function () {
return gulp.src('content/redirections/to-apps-homepage.html')
.pipe(rename('apps.html'))
.pipe(gulp.dest('./dist'))
});
gulp.task('to-app-concepts-and-use-cases', ['clean-dist', 'less'], function () {
return gulp.src('content/redirections/to-app-concepts-and-use-cases.html')
.pipe(rename('guides-index.html'))
.pipe(gulp.dest('./dist'))
});
gulp.task('build-concepts', ['clean-dist','less'], function () {
var pages = {
'products.md': 'Products',
'catalog-structure.md': 'Catalog structure',
'target-market-settings.md': 'Target market settings',
'reference-entities.md': 'Reference entities',
'asset-manager.md': 'Asset Manager',
'pam.md': 'PAM <em>- Deprecated</em>'
};
var isOnePage = false;
return gulp.src('content/concepts/*.md')
.pipe(flatmap(function(stream, file){
return gulp.src('content/concepts/*.md')
.pipe(insert.wrap("::::: mainContent\n", "\n:::::"))
.pipe(insert.prepend(getTocMarkdown(isOnePage, pages, path.basename(file.path), '/concepts') + "\n"))
.pipe(gulpMarkdownIt(md))
.pipe(gulp.dest('tmp/concepts/'))
.on('end', function () {
return gulp.src('src/partials/documentation.handlebars')
.pipe(gulpHandlebars({
active_api_resources: true,
title: 'Concepts & resources',
description: getPageDescription(file.path),
mainContent: fs.readFileSync('tmp/concepts/' + path.basename(file.path).replace(/\.md/, '.html'))
}, {
partialsDirectory: ['./src/partials']
}))
.pipe(rename(path.basename(file.path).replace(/\.md/, '.html')))
.pipe(revReplace({manifest: gulp.src("./tmp/rev/rev-manifest.json")}))
.pipe(gulp.dest('./dist/concepts'));
})
}));
}
);
gulp.task('create-app-catalog-md', function () {
return gulp.src(['content/php-client/resources/app-catalog/app-catalog.md','content/php-client/resources/app-catalog/app-catalog.md','content/php-client/resources/app-catalog/*.md'])
.pipe(concat('app-catalog.md'))
.pipe(insert.prepend('## Catalogs for Apps <span class="label label-beta">Beta</span>\n'))
.pipe(gulp.dest('tmp/php-client-resources/'));
});
gulp.task('create-products-md', function () {
return gulp.src(['content/php-client/resources/products/products.md',
'content/php-client/resources/products/products-uuid.md',
'content/php-client/resources/products/product-models.md',
'content/php-client/resources/products/product-drafts-uuid.md',
'content/php-client/resources/products/*.md'])
.pipe(concat('products.md'))
.pipe(insert.prepend('## Products\n'))
.pipe(gulp.dest('tmp/php-client-resources/'));
});
gulp.task('create-catalog-structure-md', function () {
return gulp.src(['content/php-client/resources/catalog-structure/*.md'])
.pipe(concat('catalog-structure.md'))
.pipe(insert.prepend('## Catalog structure\n'))
.pipe(gulp.dest('tmp/php-client-resources/'));
});
gulp.task('create-target-market-settings-md', function () {
return gulp.src(['content/php-client/resources/target-market-settings/*.md'])
.pipe(concat('target-market-settings.md'))
.pipe(insert.prepend('## Target market settings\n'))
.pipe(gulp.dest('tmp/php-client-resources/'));
});
gulp.task('create-PAM-md', function () {
return gulp.src(['content/php-client/resources/PAM/*.md'])
.pipe(concat('PAM.md'))
.pipe(insert.prepend('## PAM <em>- Deprecated</em>\n'))
.pipe(gulp.dest('tmp/php-client-resources/'));
});
gulp.task('create-reference-entity-md', function () {
return gulp.src(['content/php-client/resources/reference-entity/reference-entities.md', 'content/php-client/resources/reference-entity/*.md'])
.pipe(concat('reference-entity.md'))
.pipe(insert.prepend('## Reference entities\n'))
.pipe(gulp.dest('tmp/php-client-resources/'));
});
gulp.task('create-asset-manager-md', function () {
return gulp.src(['content/php-client/resources/asset-manager/assets.md', 'content/php-client/resources/asset-manager/*.md'])
.pipe(concat('asset-manager.md'))
.pipe(insert.prepend('## Asset Manager\n'))
.pipe(gulp.dest('tmp/php-client-resources/'));
});
gulp.task('create-resources-md', ['create-app-catalog-md','create-products-md','create-catalog-structure-md', 'create-target-market-settings-md', 'create-PAM-md', 'create-reference-entity-md', 'create-asset-manager-md'], function () {
return gulp.src(['tmp/php-client-resources/products.md',
'tmp/php-client-resources/catalog-structure.md',
'tmp/php-client-resources/target-market-settings.md',
'tmp/php-client-resources/asset-manager.md',
'tmp/php-client-resources/PAM.md',
'tmp/php-client-resources/reference-entity.md',
'tmp/php-client-resources/app-catalog.md'])
.pipe(concat('resources.md'))
.pipe(insert.prepend('# Resources\n'))
.pipe(gulp.dest('tmp/php-client'));
});
gulp.task('build-php-client', ['clean-dist','less', 'create-resources-md'], function () {
var pages = {
'introduction.md': 'Introduction',
'getting-started.md': 'Getting started',
'authentication.md': 'Authentication',
'exception.md': 'Exception handling',
'http-client.md': 'HTTP client abstraction',
'list-resources.md': 'List resources',
'resources.md': 'Resources'
};
var isOnePage = false;
return gulp.src(['content/php-client/*.md', 'tmp/php-client/resources.md'])