1 |
|
2 |
|
3 |
|
4 | class documentationController extends nodefony.Controller {
|
5 |
|
6 | constructor(container, context) {
|
7 | super(container, context);
|
8 |
|
9 | this.startSession();
|
10 | }
|
11 |
|
12 | |
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | searchAction() {
|
20 | return new Promise((resolve, reject)=>{
|
21 | try {
|
22 | let url = this.generateUrl("nodefony-doc", {
|
23 | bundle: "nodefony"
|
24 |
|
25 | }, true);
|
26 | if (this.query.search) {
|
27 | let webCrawler = this.get("webCrawler");
|
28 | webCrawler.siteAll(url, this.query.search, this.context, (data) => {
|
29 | return resolve( this.renderJson(data) );
|
30 | });
|
31 | } else {
|
32 | return resolve(this.renderJson({}));
|
33 | }
|
34 | }catch(e){
|
35 | return reject(e);
|
36 | }
|
37 | });
|
38 |
|
39 | }
|
40 |
|
41 | |
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | notesAction() {
|
49 | this.hideDebugBar();
|
50 | return this.render("documentation:documentation/slides/notes:notes.html.twig");
|
51 | }
|
52 |
|
53 | |
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | slidesAction(bundle) {
|
62 | this.hideDebugBar();
|
63 | let readme = null;
|
64 | if (bundle === "nodefony") {
|
65 | readme = path.resolve(this.kernel.rootDir, "README.md");
|
66 | return this.render("documentation:documentation/slides:index.html.twig", {
|
67 | title: "README",
|
68 | readme: this.htmlMdParser(new nodefony.fileClass(readme).content())
|
69 | });
|
70 | } else {
|
71 | return this.forward(`${bundle}:documentation:slides`);
|
72 | }
|
73 | }
|
74 |
|
75 | |
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 | |
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 | indexAction(bundle) {
|
92 | if (bundle === "nodefony") {
|
93 | return this.render(`documentation:documentation:index.html.twig`, {
|
94 | title: bundle,
|
95 | bundle: this.kernel.bundles,
|
96 | url: this.bundle.settings.github.url
|
97 | });
|
98 | } else {
|
99 | try {
|
100 | return this.forward(`${bundle}:documentation:index`);
|
101 | }catch(e){
|
102 | return this.render(`documentation:documentation:progress.html.twig`, {
|
103 | title: bundle,
|
104 | bundle: bundle
|
105 | });
|
106 | }
|
107 | }
|
108 | }
|
109 |
|
110 | |
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 | readmeAction(bundle) {
|
119 | let readme = null;
|
120 | if (bundle === "nodefony") {
|
121 | readme = path.resolve(this.kernel.rootDir, "README.md");
|
122 | return this.render("documentation:documentation:readme.html.twig", {
|
123 | title: "README",
|
124 | readme: this.htmlMdParser(new nodefony.fileClass(readme).content(), {
|
125 | linkify: true,
|
126 | typographer: true
|
127 | })
|
128 | });
|
129 | } else {
|
130 | if (this.kernel.bundles[bundle]) {
|
131 | readme = path.resolve(this.kernel.bundles[bundle].path, "README.md");
|
132 | }
|
133 | return this.render(`${bundle}:documentation:readme.html.twig`, {
|
134 | title: "README",
|
135 | readme: this.htmlMdParser(new nodefony.fileClass(readme).content(), {
|
136 | linkify: true,
|
137 | typographer: true
|
138 | })
|
139 | });
|
140 | }
|
141 | }
|
142 |
|
143 | |
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 | nodefonyAction(section, subsection) {
|
150 | if (subsection) {
|
151 | return this.render(`documentation:nodefony/${section}/${subsection}:index.html.twig`, {});
|
152 | }
|
153 | return this.render(`documentation:nodefony/${section}:index.html.twig`, {});
|
154 | }
|
155 |
|
156 |
|
157 | |
158 |
|
159 |
|
160 |
|
161 | langAction() {
|
162 | if (this.query.language) {
|
163 | if (this.session) {
|
164 | this.session.set("lang", this.query.language);
|
165 | let route = this.session.getMetaBag("lastRoute");
|
166 | if (route) {
|
167 | return this.redirect(this.url(route));
|
168 | }
|
169 | }
|
170 | }
|
171 | let referer = this.request.getHeader("referer");
|
172 | if (referer) {
|
173 | return this.redirect(referer);
|
174 | }
|
175 | return this.redirect("/");
|
176 | }
|
177 |
|
178 | |
179 |
|
180 |
|
181 | headerAction(version) {
|
182 | return this.render("documentation:documentation:header.html.twig", {
|
183 | langs: this.get("translation").getLangs(),
|
184 | locale: this.getLocale(),
|
185 | version: version || this.defaultVersion,
|
186 | bundle: "nodefony"
|
187 | });
|
188 | }
|
189 |
|
190 | |
191 |
|
192 |
|
193 | footerAction() {
|
194 | let version = this.kernel.settings.version;
|
195 | return this.render("documentation:documentation:footer.html.twig", {
|
196 | version: version,
|
197 | year: new Date().getFullYear()
|
198 | });
|
199 | }
|
200 |
|
201 | }
|
202 |
|
203 | module.exports = documentationController;
|