Skip to content

Commit b66a08b

Browse files
committed
add scala website, refactor CodeMirror generation
1 parent 35fdf7c commit b66a08b

File tree

11 files changed

+260
-224
lines changed

11 files changed

+260
-224
lines changed

Diff for: constants.py

+87-25
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616
LEARNCS_DOMAIN = "learncs.org"
1717
LEARNHTML_DOMAIN = "learn-html.org"
1818
LEARNGO_DOMAIN = "learn-golang.org"
19+
LEARNSCALA_DOMAIN = "learnscala.org"
20+
LEARNSOLIDITY_DOMAIN = "learnsolidity.org"
1921

2022
DOMAIN_DATA = {
2123
LEARNPYTHON_DOMAIN : {
2224
"language" : "python",
25+
"codemirror_mode": "python",
26+
"prism_mode": "language-python",
2327
"analytics" : "UA-22741967-1",
2428
"namespace" : "learnpython.org",
2529
"full_url" : "http://learnpython.org",
@@ -30,9 +34,7 @@
3034
"logo" : "/static/img/logos/learnpython.png",
3135
"share_logo" : "/static/img/share-logos/learnpython-share.png",
3236
"language_uppercase" : "Python",
33-
"twitter" : "@learnpython",
3437
"favicon" : "favicon-learnpython.ico",
35-
"copyright" : "Copyright © LearnPython.org.",
3638
"default_code" : """# Welcome to the Interactive Python Tutorial.
3739
# Start by choosing a chapter and
3840
# write your code in this window.
@@ -42,6 +44,8 @@
4244
},
4345
LEARNHTML_DOMAIN : {
4446
"language" : "html",
47+
"codemirror_mode": "text/html",
48+
"prism_mode": "language-html",
4549
"analytics" : "UA-22741967-11",
4650
"namespace" : "learn-html.org",
4751
"full_url" : "http://learn-html.org",
@@ -52,9 +56,7 @@
5256
"logo" : "/static/img/logos/learnhtml.png",
5357
"share_logo" : "/static/img/share-logos/learnhtml-share.png",
5458
"language_uppercase" : "HTML",
55-
"twitter" : "@learnhtml",
5659
"favicon" : "favicon-learnhtml.ico",
57-
"copyright" : "Copyright © Learn-HTML.org.",
5860
"default_code" : """<!-- Welcome to the Interactive HTML & CSS Tutorial.
5961
Start by choosing a chapter and
6062
write your code in this window.
@@ -73,6 +75,8 @@
7375

7476
LEARNC_DOMAIN : {
7577
"language" : "c",
78+
"codemirror_mode": "text/x-csrc",
79+
"prism_mode": "language-c",
7680
"analytics" : "UA-22741967-3",
7781
"namespace" : "learn-c.org",
7882
"full_url" : "http://learn-c.org",
@@ -83,9 +87,7 @@
8387
"logo" : "/static/img/logos/learn-c.png",
8488
"share_logo" : "/static/img/share-logos/learn-c-share.png",
8589
"language_uppercase" : "C",
86-
"twitter" : "@learnc",
8790
"favicon" : "favicon-learn-c.ico",
88-
"copyright" : "Copyright &copy; Learn-C.org. ",
8991
"default_code" : """/* Welcome to the Interactive C Tutorial.
9092
Start by choosing a chapter and
9193
write your code in this window. */
@@ -109,6 +111,8 @@
109111
},
110112
LEARNCPP_DOMAIN : {
111113
"language" : "c++11",
114+
"codemirror_mode": "text/x-csrc",
115+
"prism_mode": "language-cpp",
112116
"analytics" : "UA-22741967-12",
113117
"namespace" : "learn-cpp.org",
114118
"full_url" : "http://learn-cpp.org",
@@ -119,9 +123,7 @@
119123
"logo" : "/static/img/logos/learn-cpp.png",
120124
"share_logo" : "/static/img/share-logos/learn-cpp-share.png",
121125
"language_uppercase" : "C++",
122-
"twitter" : "@learncpp",
123126
"favicon" : "favicon-learn-cpp.ico",
124-
"copyright" : "Copyright &copy; Learn-cpp.org. ",
125127
"default_code" : """// Welcome to the Interactive C++ Tutorial.
126128
// Start by choosing a chapter and
127129
// write your code in this window.
@@ -147,6 +149,8 @@
147149
},
148150
LEARNJAVA_DOMAIN : {
149151
"language" : "java",
152+
"codemirror_mode": "text/x-java",
153+
"prism_mode": "language-java",
150154
"analytics" : "UA-22741967-4",
151155
"namespace" : "learnjavaonline.org",
152156
"full_url" : "http://learnjavaonline.org",
@@ -157,9 +161,7 @@
157161
"logo" : "/static/img/logos/learnjavaonline.png",
158162
"share_logo" : "/static/img/share-logos/learnjavaonline-share.png",
159163
"language_uppercase" : "Java",
160-
"twitter" : "@learnjava",
161164
"favicon" : "favicon-learnjava.ico",
162-
"copyright" : "Copyright &copy; LearnJavaOnline.org.",
163165
"default_code" : """// Welcome to the Interactive Java Tutorial.
164166
// Start by choosing a chapter and
165167
// write your code in this window.
@@ -186,6 +188,8 @@
186188
},
187189
LEARNJS_DOMAIN : {
188190
"language" : "javascript",
191+
"codemirror_mode": "text/javascript",
192+
"prism_mode": "language-javascript",
189193
"analytics" : "UA-22741967-5",
190194
"namespace" : "learn-js.org",
191195
"full_url" : "http://learn-js.org",
@@ -196,9 +200,7 @@
196200
"logo" : "/static/img/logos/learn-js.png",
197201
"share_logo" : "/static/img/share-logos/learn-js-share.png",
198202
"language_uppercase" : "JavaScript",
199-
"twitter" : "@learnjs",
200203
"favicon" : "favicon-learn-js.ico",
201-
"copyright" : "Copyright &copy; Learn-JS.org.",
202204
"default_code" : """// Welcome to the Interactive JavaScript Tutorial.
203205
// Start by choosing a chapter and
204206
// write your code in this window.
@@ -208,8 +210,10 @@
208210
},
209211
LEARNRUBY_DOMAIN : {
210212
"language" : "ruby",
213+
"codemirror_mode": "text/x-ruby",
214+
"prism_mode": "language-ruby",
211215
"analytics" : "UA-22741967-6",
212-
"namespace" : "learnrubyonline.org",
216+
"namespace" : "learnrubyonline.org",
213217
"full_url" : "http://learnrubyonline.org",
214218
"sender" : "Learn-JS.org <[email protected]>",
215219
"styled_domain" : "LearnRubyOnline.org",
@@ -218,9 +222,7 @@
218222
"logo" : "/static/img/logos/learnrubyonline.png",
219223
"share_logo" : "/static/img/share-logos/learnrubyonline-share.png",
220224
"language_uppercase" : "Ruby",
221-
"twitter" : "@learnruby",
222225
"favicon" : "favicon-ruby.ico",
223-
"copyright" : "Copyright &copy; LearnRubyOnline.org.",
224226
"default_code" : """# Welcome to the Interactive Ruby Tutorial.
225227
# Start by choosing a chapter and
226228
# write your code in this window.
@@ -230,6 +232,8 @@
230232
},
231233
LEARNSHELL_DOMAIN : {
232234
"language" : "bash",
235+
"codemirror_mode": "text/x-sh",
236+
"prism_mode": "language-bash",
233237
"analytics" : "UA-22741967-7",
234238
"namespace" : "learnshell.org",
235239
"full_url" : "http://learnshell.org",
@@ -240,9 +244,7 @@
240244
"logo" : "/static/img/logos/learnshell.png",
241245
"share_logo" : "/static/img/share-logos/learnshell-share.png",
242246
"language_uppercase" : "Shell Programming",
243-
"twitter" : "@learnshell",
244247
"favicon" : "favicon-shell.ico",
245-
"copyright" : "Copyright &copy; LearnShell.org.",
246248
"default_code" : """#!/bin/bash
247249
# Welcome to the Interactive Shell Tutorial.
248250
# Start by choosing a chapter and
@@ -254,6 +256,8 @@
254256

255257
LEARNPERL_DOMAIN : {
256258
"language" : "perl",
259+
"codemirror_mode": "text/x-perl",
260+
"prism_mode": "language-perl",
257261
"analytics" : "UA-22741967-8",
258262
"namespace" : "learn-perl.org",
259263
"full_url" : "http://learn-perl.org",
@@ -264,9 +268,7 @@
264268
"logo" : "/static/img/logos/learn-perl.png",
265269
"share_logo" : "/static/img/share-logos/learn-perl-share.png",
266270
"language_uppercase" : "Perl",
267-
"twitter" : "@learnperl",
268271
"favicon" : "favicon-learn-perl.ico",
269-
"copyright" : "Copyright &copy; Learn-Perl.org.",
270272
"default_code" : """# Welcome to the Interactive Perl Tutorial.
271273
# Start by choosing a chapter and write your code in this window.
272274
@@ -275,6 +277,8 @@
275277

276278
LEARNPHP_DOMAIN : {
277279
"language" : "php",
280+
"codemirror_mode": "application/x-httpd-php",
281+
"prism_mode": "language-php",
278282
"analytics" : "UA-22741967-9",
279283
"namespace" : "learn-php.org",
280284
"full_url" : "http://learn-php.org",
@@ -285,9 +289,7 @@
285289
"logo" : "/static/img/logos/learn-php.png",
286290
"share_logo" : "/static/img/share-logos/learn-php-share.png",
287291
"language_uppercase" : "PHP",
288-
"twitter" : "@learnphp",
289292
"favicon" : "favicon-learn-php.ico",
290-
"copyright" : "Copyright &copy; Learn-PHP.org.",
291293
"default_code" : """<?php
292294
// Welcome to the Interactive PHP Tutorial.
293295
// Start by choosing a chapter and
@@ -305,6 +307,8 @@
305307

306308
LEARNCS_DOMAIN : {
307309
"language" : "c#",
310+
"codemirror_mode": "text/x-csharp",
311+
"prism_mode": "language-csharp",
308312
"analytics" : "UA-22741967-10",
309313
"namespace" : "learncs.org",
310314
"full_url" : "http://learncs.org",
@@ -315,9 +319,7 @@
315319
"logo" : "/static/img/logos/learncs.png",
316320
"share_logo" : "/static/img/share-logos/learncs-share.png",
317321
"language_uppercase" : "C#",
318-
"twitter" : "@learncs",
319322
"favicon" : "favicon-learncs.ico",
320-
"copyright" : "Copyright &copy; LearnCS.org.",
321323
"default_code" : """// Welcome to the Interactive C# Tutorial.
322324
// Start by choosing a chapter and write your code in this window.
323325
@@ -348,6 +350,8 @@
348350

349351
LEARNGO_DOMAIN : {
350352
"language" : "go",
353+
"codemirror_mode": "text/x-go",
354+
"prism_mode": "language-go",
351355
"analytics" : "UA-22741967-13",
352356
"namespace" : "learn-golang.org",
353357
"full_url" : "http://learn-golang.org",
@@ -358,9 +362,7 @@
358362
"logo" : "/static/img/logos/learn-golang.png",
359363
"share_logo" : "/static/img/share-logos/learn-golang-share.png",
360364
"language_uppercase" : "Go",
361-
"twitter" : "@learngolang",
362365
"favicon" : "favicon-learngolang.ico",
363-
"copyright" : "Copyright &copy; Learn-GoLang.org.",
364366
"default_code" : """// Welcome to the Interactive Go Tutorial.
365367
// Start by choosing a chapter, write your code in this window.
366368
package main
@@ -386,5 +388,65 @@
386388
}
387389
""",
388390

391+
},
392+
LEARNSCALA_DOMAIN : {
393+
"language" : "scala",
394+
"codemirror_mode": "text/x-scala",
395+
"prism_mode": "language-scala",
396+
"analytics" : "UA-22741967-14",
397+
"namespace" : "learnscala.org",
398+
"full_url" : "http://learnscala.org",
399+
"sender" : "LearnScala.org <[email protected]>",
400+
"styled_domain" : "LearnScala.org",
401+
"contact_email" : "[email protected]",
402+
"support_email" : "[email protected]",
403+
"logo" : "/static/img/logos/learnscala.png",
404+
"share_logo" : "/static/img/share-logos/learnscala-share.png",
405+
"language_uppercase" : "Scala",
406+
"favicon" : "favicon-learnscala.ico",
407+
"default_code" : """// Welcome to the Interactive Scala Tutorial.
408+
// Start by choosing a chapter, write your code in this window.
409+
object Main {
410+
def main(args: Array[String]) {
411+
println("Hello, World!\\n");
412+
}
413+
}
414+
415+
""",
416+
"container_word": "object",
417+
"container_indent": " ",
418+
"container": """object Test {
419+
def main(args: Array[String]) {
420+
println("Hello, World!\\n");
421+
}
422+
}
423+
424+
""",
425+
},
426+
LEARNSOLIDITY_DOMAIN: {
427+
"language" : "solidity",
428+
"codemirror_mode": "text/x-solidity",
429+
"prism_mode": "language-solidity",
430+
"analytics" : "UA-22741967-15",
431+
"namespace" : "learnsolidity.org",
432+
"full_url" : "http://learnsolidity.org",
433+
"sender" : "LearnSolidity.org <[email protected]>",
434+
"styled_domain" : "LearnSolidity.org",
435+
"contact_email" : "[email protected]",
436+
"support_email" : "[email protected]",
437+
"logo" : "/static/img/logos/learnsolidity.png",
438+
"share_logo" : "/static/img/share-logos/learnsolidity-share.png",
439+
"language_uppercase" : "Solidity",
440+
"favicon" : "favicon-learnsolidity.ico",
441+
"default_code" : """// Welcome to the Interactive Solidity Tutorial.
442+
// Start by choosing a chapter, write your code in this window.
443+
444+
""",
445+
"container_word" : "",
446+
"container_indent" : "",
447+
"container" : """
448+
""",
449+
450+
389451
},
390452
}

Diff for: main.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,12 @@ def untab(text):
131131

132132

133133
def init_tutorials():
134+
contributing_tutorials = wikify(open(os.path.join(os.path.dirname(__file__), "tutorials", "Contributing Tutorials.md")).read(), "en")
135+
134136
for domain in os.listdir(os.path.join(os.path.dirname(__file__), "tutorials")):
137+
if domain.endswith(".md"):
138+
continue
139+
135140
logging.warn("loading data for domain: %s", domain)
136141
tutorial_data[domain] = {}
137142
if not os.path.isdir(os.path.join(os.path.dirname(__file__), "tutorials", domain)):
@@ -190,10 +195,7 @@ def init_tutorials():
190195
if not link in tutorial_data[domain][language]:
191196
tutorial_data[domain][language][link] = {
192197
"page_title" : link.decode("utf8"),
193-
"text" : "<p>This page does not exist yet. </p>" + "<p>You can contribute this page by forking the repository at: " +
194-
"<a href='https://github.com/ronreiter/interactive-tutorials'>" +
195-
"https://github.com/ronreiter/interactive-tutorials" +
196-
"</a>.</p>",
198+
"text": contributing_tutorials,
197199
"code": ""
198200
}
199201

0 commit comments

Comments
 (0)