Created
January 13, 2023 00:48
-
-
Save popdemtech/25b86148941c33d994318c3ad93df8a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # How to Write a Book About Software | |
| # 1. Know something about Software | |
| # 2. Spend time collecting the stuff you know | |
| # 3. Use software to produce the manuscript | |
| # popdemtech | |
| #################### | |
| # SCRIPT STARTS HERE | |
| #################### | |
| require 'htmlentities' | |
| require 'redcarpet' | |
| require 'json' | |
| LESSONS_PATH = '.' | |
| @sections = [] | |
| def build_section(lesson, index) | |
| file = File.open(lesson[:instructions]) | |
| content = file.read | |
| markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true, with_toc_data: true) | |
| content = HTMLEntities.new.decode(markdown.render(content)) | |
| file.close | |
| { | |
| title: lesson[:title], | |
| slug: lesson[:route], | |
| content: content, | |
| sectionType: 'chapter', | |
| sequence: index, | |
| parentSection: { | |
| parentSectionType: @current_module[:sectionType], | |
| parentSectionSequence: @current_module[:sequence], | |
| parentSectionSlug: @current_module[:slug] | |
| } | |
| } | |
| end | |
| ############### | |
| ## | |
| ## HTML and CSS | |
| ## | |
| ############### | |
| @current_module = { | |
| title: 'HTML and CSS', | |
| slug: 'html-css', | |
| content: '', | |
| sectionType:'module', | |
| sequence: 1, | |
| parentSection: nil | |
| } | |
| wd101_lessons = [ | |
| { | |
| title: "Welcome", | |
| instructions: File.join(LESSONS_PATH, 'wd101', 'welcome.md'), | |
| route: 'welcome' | |
| }, | |
| { | |
| title: "What You'll Need", | |
| instructions: File.join(LESSONS_PATH, 'wd101', 'what-needed.md'), | |
| route: 'what-needed' | |
| }, | |
| { | |
| title: "Getting Started with HTML", | |
| instructions: File.join(LESSONS_PATH, 'wd101', 'start-html.md'), | |
| route: 'start-html' | |
| }, | |
| { | |
| title: "HTML Basics", | |
| instructions: File.join(LESSONS_PATH, 'wd101', 'html-basics.md'), | |
| route: 'html-basics' | |
| }, | |
| { | |
| title: "HTML Elements", | |
| instructions: File.join(LESSONS_PATH, 'wd101', 'html-elements.md'), | |
| route: 'html-elements' | |
| }, | |
| { | |
| title: "HTML Attributes", | |
| instructions: File.join(LESSONS_PATH, 'wd101', 'html-attrs.md'), | |
| route: 'html-attrs' | |
| }, | |
| { | |
| title: "HTML Exercise", | |
| instructions: File.join(LESSONS_PATH, 'wd101', 'basic-html-exercise.md'), | |
| route: 'basic-html-exercise' | |
| }, | |
| { | |
| title: "Introduction to CSS", | |
| instructions: File.join(LESSONS_PATH, 'wd101', 'css-basics.md'), | |
| route: 'css-basics' | |
| }, | |
| { | |
| title: "CSS Properties", | |
| instructions: File.join(LESSONS_PATH, 'wd101', 'css-props.md'), | |
| route: 'css-props' | |
| }, | |
| { | |
| title: "CSS Exercise", | |
| instructions: File.join(LESSONS_PATH, 'wd101', 'basic-css-exercise.md'), | |
| route: 'basic-css-exercise' | |
| }, | |
| { | |
| title: "Main Exercise", | |
| instructions: File.join(LESSONS_PATH, 'wd101', 'main-exercise.md'), | |
| route: 'main-exercise' | |
| }, | |
| { | |
| title: "Github", | |
| instructions: File.join(LESSONS_PATH, 'wd101', 'github.md'), | |
| route: 'github' | |
| } | |
| ] | |
| @sections.push(@current_module) | |
| wd101_lessons.each_with_index do |lesson, index| | |
| section = build_section(lesson, index) | |
| @sections.push(section) | |
| end | |
| ############### | |
| ## | |
| ## Tooling and Process | |
| ## | |
| ############### | |
| @current_module = { | |
| title: 'Intermediate Tools and Process', | |
| slug: 'tools-and-process', | |
| content: '', | |
| sectionType:'module', | |
| sequence: 2, | |
| parentSection: nil | |
| } | |
| wd102_lessons = [ | |
| { | |
| title: "Welcome", | |
| instructions: File.join(LESSONS_PATH, 'wd102', 'welcome.md'), | |
| route: 'welcome' | |
| }, | |
| { | |
| title: "What You'll Need", | |
| instructions: File.join(LESSONS_PATH, 'wd102', 'what-needed.md'), | |
| route: 'what-needed' | |
| }, | |
| { | |
| title: "Terminal Basics", | |
| instructions: File.join(LESSONS_PATH, 'wd102', 'terminal-basics.md'), | |
| route: 'terminal-basics' | |
| }, | |
| { | |
| title: "Text Editors", | |
| instructions: File.join(LESSONS_PATH, 'wd102', 'text-editors.md'), | |
| route: 'text-editors' | |
| }, | |
| { | |
| title: "Text Editor Workflow", | |
| instructions: File.join(LESSONS_PATH, 'wd102', 'text-editor-workflow.md'), | |
| route: 'text-editor-workflow' | |
| }, | |
| { | |
| title: "Git Basics", | |
| instructions: File.join(LESSONS_PATH, 'wd102', 'git-basics.md'), | |
| route: 'git-basics' | |
| }, | |
| { | |
| title: "Git Exercise", | |
| instructions: File.join(LESSONS_PATH, 'wd102', 'git-exercise.md'), | |
| route: 'git-exercise' | |
| }, | |
| { | |
| title: "Finish", | |
| instructions: File.join(LESSONS_PATH, 'wd102', 'finish.md'), | |
| route: 'finish' | |
| }, | |
| ] | |
| @sections.push(@current_module) | |
| wd102_lessons.each_with_index do |lesson, index| | |
| section = build_section(lesson, index) | |
| @sections.push(section) | |
| end | |
| ############### | |
| ## | |
| ## Intermediate HTML and Workflow | |
| ## | |
| ############### | |
| @current_module = { | |
| title: 'Intermediate HTML and Workflow', | |
| slug: 'intermediate-html', | |
| content: '', | |
| sectionType:'module', | |
| sequence: 3, | |
| parentSection: nil | |
| } | |
| wd103_lessons = [ | |
| { | |
| title: "Welcome", | |
| instructions: File.join(LESSONS_PATH, 'wd103', 'welcome.md'), | |
| route: 'welcome' | |
| }, | |
| { | |
| title: "What You'll Need", | |
| instructions: File.join(LESSONS_PATH, 'wd103', 'what-needed.md'), | |
| route: 'what-needed' | |
| }, | |
| { | |
| title: "HTML Document Flow", | |
| instructions: File.join(LESSONS_PATH, 'wd103', 'document-flow.md'), | |
| route: 'document-flow' | |
| }, | |
| { | |
| title: "Basic Positioning", | |
| instructions: File.join(LESSONS_PATH, 'wd103', 'basic-positioning.md'), | |
| route: 'basic-positioning' | |
| }, | |
| { | |
| title: "Flexbox", | |
| instructions: File.join(LESSONS_PATH, 'wd103', 'flexbox.md'), | |
| route: 'flexbox' | |
| }, | |
| { | |
| title: "Git Branching", | |
| instructions: File.join(LESSONS_PATH, 'wd103', 'git-branching.md'), | |
| route: 'git-branching' | |
| }, | |
| { | |
| title: "Team Git", | |
| instructions: File.join(LESSONS_PATH, 'wd103', 'team-git.md'), | |
| route: 'team-git' | |
| } | |
| ] | |
| @sections.push(@current_module) | |
| wd103_lessons.each_with_index do |lesson, index| | |
| section = build_section(lesson, index) | |
| @sections.push(section) | |
| end | |
| File.write('webdev101.json', JSON.pretty_generate(@sections)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment