hs-cli 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1f1911dbebb05033050a47fb13af39c36f91381f8787aac030660fe93425d4a
4
- data.tar.gz: 64a451d68bd3b611090bb95c997e6f1e8eed4e6c322325cae71fe84805a2b468
3
+ metadata.gz: afc4b0f4d4ced43015bb231e2f1f5ac5f9718d894d05e5693f347b9a9a470265
4
+ data.tar.gz: 5dc88339bbec902c7cc61dc2dfc91bb9c517ddf86de34c060f1ae866be960739
5
5
  SHA512:
6
- metadata.gz: 785b085c2b24c4f3a19da3fd39a5a9ff727698d057fb3394503471abb105b83c118fc04381327760813755e3d01586d598785bb753b456fe619e74dfa09ca463
7
- data.tar.gz: 68c80f160635c6e63e2878e3b74cebe099d431aa538e1351afc132da41fa5b0cb5debe94bcf9d2d1c874455bc6ba98479740e77c3c6e13c01805213c081a8a6a
6
+ metadata.gz: 7deedf1c8db3b2e0493ac7ff951a58e8f272f8a1519e6c3ff4f37a0df373e20f496458a5fff62ce7c2d6860bcde5a0d5c1bb7aec03fbaff6b4bed26ca9c810ac
7
+ data.tar.gz: 1a8d255f8d7440554326e4d57859d4eae1409f21f700d5303aa23477c64548624808e28b3b9bf81ebd1a58542f65034c63d6252e0d5aa8e5198c886381fefe23
data/Gemfile.lock CHANGED
@@ -1,9 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hs-cli (0.1.2)
4
+ hs-cli (0.2.0)
5
5
  activesupport (~> 5.2)
6
- nokogiri (> 1)
6
+ nokogiri (~> 1.8)
7
+ rack-contrib (~> 2.0)
8
+ sinatra (~> 2.0)
9
+ thor (~> 0.20)
7
10
 
8
11
  GEM
9
12
  remote: https://rubygems.org/
@@ -23,6 +26,7 @@ GEM
23
26
  method_source (0.9.0)
24
27
  mini_portile2 (2.3.0)
25
28
  minitest (5.11.3)
29
+ mustermann (1.0.3)
26
30
  nokogiri (1.8.4)
27
31
  mini_portile2 (~> 2.3.0)
28
32
  parallel (1.12.1)
@@ -32,6 +36,11 @@ GEM
32
36
  pry (0.11.3)
33
37
  coderay (~> 1.1.0)
34
38
  method_source (~> 0.9.0)
39
+ rack (2.0.5)
40
+ rack-contrib (2.0.1)
41
+ rack (~> 2.0)
42
+ rack-protection (2.0.3)
43
+ rack
35
44
  rainbow (3.0.0)
36
45
  rake (10.5.0)
37
46
  rspec (3.8.0)
@@ -63,7 +72,14 @@ GEM
63
72
  rubocop-rspec (1.27.0)
64
73
  rubocop (>= 0.56.0)
65
74
  ruby-progressbar (1.10.0)
75
+ sinatra (2.0.3)
76
+ mustermann (~> 1.0)
77
+ rack (~> 2.0)
78
+ rack-protection (= 2.0.3)
79
+ tilt (~> 2.0)
80
+ thor (0.20.0)
66
81
  thread_safe (0.3.6)
82
+ tilt (2.0.8)
67
83
  tzinfo (1.2.5)
68
84
  thread_safe (~> 0.1)
69
85
  unicode-display_width (1.4.0)
@@ -74,13 +90,13 @@ PLATFORMS
74
90
  DEPENDENCIES
75
91
  bundler (~> 1.16)
76
92
  hs-cli!
77
- pry (> 0.11)
93
+ pry (~> 0.11)
78
94
  rake (~> 10.0)
79
95
  rspec (~> 3.0)
80
96
  rspec-collection_matchers (~> 1.1)
81
97
  rspec-its (~> 1.2)
82
- rubocop (> 0.58)
83
- rubocop-rspec (> 1.20)
98
+ rubocop (~> 0.58)
99
+ rubocop-rspec (~> 1.20)
84
100
 
85
101
  BUNDLED WITH
86
102
  1.16.3
data/README.md CHANGED
@@ -1,32 +1,82 @@
1
1
  [![Build Status](https://travis-ci.org/hackersrc/hs-cli.svg?branch=master)](https://travis-ci.org/hackersrc/hs-cli)
2
2
 
3
- # HS
3
+ # hs-cli
4
4
 
5
- ## ინსტალაცია
5
+ ## Installation
6
6
 
7
7
  $ gem install hs-cli
8
8
 
9
- ## გამოყენება
9
+ ## Usage
10
+
11
+ ### Local server
12
+
13
+ If your course XML path is at `content/course.xml` you
14
+ can start local server using command:
15
+
16
+ ```sh
17
+ hscli content/course.xml
18
+ ```
19
+
20
+ You should be able to see your course on
21
+ [localhost:8080](http://localhost:8080).
22
+
23
+ ### Course XML format
24
+
25
+ Example of course XML file:
26
+
27
+ ```xml
28
+ <?xml version="1.0" encoding="UTF-8"?>
29
+ <course
30
+ slug="getting-started-with-the-web"
31
+ >
32
+ <title>
33
+ ვებ დეველოპმენტი დამწყებთათვის
34
+ </title>
35
+
36
+ <chapters>
37
+ <chapter file="01-overview.xml" />
38
+ <chapter file="02-basic-software.xml" />
39
+ <chapter file="03-what-will-your-website-look-like.xml" />
40
+ <chapter file="04-dealing-with-files.xml" />
41
+ <chapter file="05-html-basics.xml" />
42
+ <chapter file="06-css-basics.xml" />
43
+ <chapter file="07-js-basics.xml" />
44
+ <chapter file="08-publishing-your-website.xml" />
45
+ <chapter file="09-how-the-web-works.xml" />
46
+ </chapters>
47
+ </course>
48
+ ```
49
+
50
+ ### Chapter XML format
51
+
52
+ Example of chapter XML file:
53
+
54
+ ```xml
55
+ <?xml version="1.0" encoding="UTF-8"?>
56
+ <chapter slug="overview">
57
+ <title>
58
+ კურსის მიმოხილვა
59
+ </title>
60
+
61
+ <intro>
62
+ "ვებ დეველოპმენტი დამწყებთათვის" არის პრაქტიკული ვებ პროგრამირების მოკლე კურსი.
63
+ თქვენ შეისწავლით როგორ შექმნათ და გამოაქვეყნოთ მარტივი ვებგვერდის კოდი.
64
+ </intro>
65
+
66
+ <p>
67
+ პროფესიონალური ვებსაიტის შექმნა ბევრ შრომას მოითხოვს.
68
+ თუ დამწყები ხართ სჯობს არ აჩქარდეთ, რადგან დღესვე შემდეგი
69
+ ფეისბუკის შექმნა გაგიჭირდებათ.
70
+ მაგრამ თქვენი მარტივი ვებგვერდის ინტერნეტში გაშვება არაა რთული.
71
+ </p>
72
+ </chapter>
73
+ ```
74
+
75
+ ### More examples
76
+
77
+ You can find out more looking at our
78
+ [example course repo](https://github.com/hackersrc/getting-started-with-the-web).
10
79
 
11
- ### კონფიგურაცია
12
-
13
- ფაილი `.hs` გამოიყენება კონფიგურაციის ჩასაწერად.
14
-
15
- კონფიგურაციაში ჩაწერეთ თქვენი მომხარებელი და პაროლი,
16
- რომლითაც ხართ რეგისტრირებული [ჰაკერების სკოლაში](http://hackerschool.ge).
17
-
18
- USERNAME=dimitri
19
- PASSWORD=secret
20
-
21
- ### ბრაძანებები
22
-
23
- სტატიკური კურსის გენერაცია შეგიძლიათ ბრძანებით:
24
-
25
- $ hs --out=html
26
-
27
- კურსის ატვირთვა [ჰაკერების სკოლაში](http://hackerschool.ge):
28
-
29
- $ hs --sync
30
80
 
31
81
  ## Development
32
82
 
@@ -0,0 +1,21 @@
1
+ .note {
2
+ margin: 2em 0;
3
+ background-color: #ffc;
4
+ padding: 32px;
5
+ max-width: 960px;
6
+ }
7
+
8
+ .note.important {
9
+ background-color: #fcc;
10
+ }
11
+
12
+ pre {
13
+ border-left: 3px solid rgba(0, 0, 255, 0.75) !important;
14
+ padding: 1em;
15
+ background-color: rgba(190, 200, 255, 0.25);
16
+ }
17
+
18
+ .wrong-code {
19
+ border-left: 3px solid rgba(255, 0, 0, 0.75) !important;
20
+ background-color: rgba(255, 0, 0, 0.05);
21
+ }
@@ -0,0 +1,6 @@
1
+ <div class="uk-container">
2
+ <p>
3
+ &copy; 2018
4
+ <a href="http://hakcerschool.ge">ჰაკერების სკოლა</a>
5
+ </p>
6
+ </div>
@@ -0,0 +1,14 @@
1
+ <hr />
2
+
3
+ <div class="uk-container">
4
+ <ul class="uk-breadcrumb">
5
+ <li>
6
+ <a href="/"><%= course %></a>
7
+ </li>
8
+ <li>
9
+ <span><%= chapter %></span>
10
+ </li>
11
+ </ul>
12
+ </div>
13
+
14
+ <hr />
@@ -0,0 +1,20 @@
1
+ <div class="uk-section">
2
+ <div class="uk-container">
3
+ <h1>
4
+ <%= @chapter.title %>
5
+ </h1>
6
+ </div>
7
+
8
+
9
+
10
+ <%= erb :_nav, layout: false, locals: { course: @course.title, chapter: @chapter.title } %>
11
+
12
+
13
+
14
+ <div class="uk-container">
15
+ <%= @chapter.preview %>
16
+ </div>
17
+
18
+ <%= erb :_nav, layout: false, locals: { course: @course.title, chapter: @chapter.title } %>
19
+ <%= erb :_footer, layout: false %>
20
+ </div>
@@ -0,0 +1,28 @@
1
+ <div class="uk-section">
2
+ <div class="uk-container">
3
+ <h1 class="uk-heading">
4
+ <%= @course.title %>
5
+ </h1>
6
+ </div>
7
+
8
+ <hr />
9
+
10
+ <div class="uk-container">
11
+ <h2 class="toc-title">
12
+ კურსის შინაარსი
13
+ </h2>
14
+
15
+ <ol class="toc">
16
+ <% @course.chapters.each do |chapter| %>
17
+ <li>
18
+ <a href="/<%= chapter.slug %>">
19
+ <%= chapter.title %>
20
+ </a>
21
+ </li>
22
+ <% end %>
23
+ </ol>
24
+ </div>
25
+
26
+ <hr />
27
+ <%= erb :_footer, layout: false %>
28
+ </div>
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title><%= @title %></title>
7
+ <link rel="stylesheet" href="/default.css" />
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-rc.10/css/uikit.min.css" />
9
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-rc.10/js/uikit.min.js"></script>
10
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-rc.10/js/uikit-icons.min.js"></script>
11
+ </head>
12
+ <body>
13
+ <%= yield %>
14
+ </body>
15
+ </html>
data/exe/hscli ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'thor'
6
+ require 'hs'
7
+
8
+ class Hscli < Thor
9
+ desc 'start ENTRY', 'starts local development server for ENTRY'
10
+ method_option :bind, aliases: '-b', desc: 'Bind address', default: '0.0.0.0'
11
+ method_option :port, aliases: '-p', desc: 'Port ', default: '8080'
12
+ def start(entry)
13
+ HS::DevServer.create(
14
+ bind: options[:bind],
15
+ port: options[:port],
16
+ entry: entry
17
+ ).run!
18
+ end
19
+ end
20
+
21
+ Hscli.start
data/hs.gemspec CHANGED
@@ -28,14 +28,17 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
28
28
  spec.require_paths = ['lib']
29
29
 
30
30
  spec.add_dependency 'activesupport', '~> 5.2'
31
- spec.add_dependency 'nokogiri', '> 1'
31
+ spec.add_dependency 'nokogiri', '~> 1.8'
32
+ spec.add_dependency 'rack-contrib', '~> 2.0'
33
+ spec.add_dependency 'sinatra', '~> 2.0'
34
+ spec.add_dependency 'thor', '~> 0.20'
32
35
 
33
36
  spec.add_development_dependency 'bundler', '~> 1.16'
34
- spec.add_development_dependency 'pry', '> 0.11'
37
+ spec.add_development_dependency 'pry', '~> 0.11'
35
38
  spec.add_development_dependency 'rake', '~> 10.0'
36
39
  spec.add_development_dependency 'rspec', '~> 3.0'
37
40
  spec.add_development_dependency 'rspec-collection_matchers', '~> 1.1'
38
41
  spec.add_development_dependency 'rspec-its', '~> 1.2'
39
- spec.add_development_dependency 'rubocop', '> 0.58'
40
- spec.add_development_dependency 'rubocop-rspec', '> 1.20'
42
+ spec.add_development_dependency 'rubocop', '~> 0.58'
43
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.20'
41
44
  end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'sinatra/base'
4
+ require 'rack/contrib/try_static'
5
+
6
+ module HS
7
+ class DevServer
8
+ class << self
9
+ attr_accessor :app, :entry
10
+
11
+ def create(config = {})
12
+ self.entry = config[:entry] || 'content/course.xml'
13
+ self.app = initialize_application(config)
14
+ set_root_route
15
+ set_chapter_route
16
+ app
17
+ end
18
+
19
+ private
20
+
21
+ def initialize_application(config)
22
+ public_folder = config[:public_folder] || 'public'
23
+ hs_public_folder = File.expand_path('../../app/public', __dir__)
24
+ Sinatra.new do
25
+ set(:bind, '0.0.0.0')
26
+ set(:port, 8080)
27
+ set(:views, File.expand_path('../../app/views', __dir__))
28
+ set(:public_folder, public_folder)
29
+ use(Rack::TryStatic, root: hs_public_folder, urls: %w[/])
30
+ end
31
+ end
32
+
33
+ def set_root_route
34
+ entry = self.entry
35
+
36
+ app.get '/' do
37
+ @course = HS::Course.load(entry)
38
+ @title = @course.title
39
+
40
+ erb :course
41
+ end
42
+ end
43
+
44
+ def set_chapter_route
45
+ entry = self.entry
46
+
47
+ app.get '/:slug' do
48
+ @course = HS::Course.load(entry)
49
+ @chapter = @course.find_chapter(params[:slug])
50
+ @title = @chapter.title
51
+
52
+ erb :chapter
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -3,7 +3,7 @@
3
3
  module HS
4
4
  class Intro < HS::Element
5
5
  def default_class
6
- 'intro'
6
+ 'uk-text-lead'
7
7
  end
8
8
  end
9
9
  end
@@ -28,6 +28,10 @@ module HS
28
28
  @chapters = []
29
29
  end
30
30
 
31
+ def find_chapter(slug)
32
+ chapters.find { |c| c.slug == slug }
33
+ end
34
+
31
35
  def hs_url
32
36
  "#{HS::Config.publish_url}/learn/#{slug}"
33
37
  end
@@ -7,30 +7,16 @@ module HS
7
7
  include HS::HTMLPreview
8
8
 
9
9
  def preview
10
- html_preview do
11
- body_element
12
- end
13
- end
14
-
15
- def toc_preview
16
- "<li><a href=\"/#{slug}\">#{title.strip}</a></li>"
17
- end
18
-
19
- def save_preview
20
- file = "#{HS::Config.preview_dir}/#{slug}.html"
21
- File.open(file, 'w') { |f| f.write(preview) }
10
+ body_element
22
11
  end
23
12
 
24
13
  private
25
14
 
26
15
  def body_element
27
16
  [
28
- '<body>',
29
- title_preview,
30
17
  intro_preview,
31
- content_preview,
32
- '</body>'
33
- ]
18
+ content_preview
19
+ ].join("\n")
34
20
  end
35
21
 
36
22
  def intro_preview
@@ -38,10 +24,6 @@ module HS
38
24
  intro.preview
39
25
  end
40
26
 
41
- def title_preview
42
- "<h1 class=\"title\">#{title.strip}</h1>"
43
- end
44
-
45
27
  def content_preview
46
28
  content.map(&:preview).compact.join
47
29
  end
data/lib/hs/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HS
4
- VERSION = '0.1.2'
4
+ VERSION = '0.2.0'
5
5
  end
data/lib/hs.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  require 'hs/version'
4
4
  require 'hs/config'
5
5
 
6
- require 'hs/course'
7
- require 'hs/chapter'
6
+ require 'hs/models/course'
7
+ require 'hs/models/chapter'
8
8
 
9
9
  require 'hs/elements/element'
10
10
  require 'hs/elements/br'
@@ -26,3 +26,5 @@ require 'hs/elements/strong'
26
26
  require 'hs/elements/table'
27
27
  require 'hs/elements/text'
28
28
  require 'hs/elements/ul'
29
+
30
+ require 'hs/devserver'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hs-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Kurashvili
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-21 00:00:00.000000000 Z
11
+ date: 2018-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -28,16 +28,58 @@ dependencies:
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">"
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1'
33
+ version: '1.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">"
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1'
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack-contrib
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sinatra
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: thor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.20'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.20'
41
83
  - !ruby/object:Gem::Dependency
42
84
  name: bundler
43
85
  requirement: !ruby/object:Gem::Requirement
@@ -56,14 +98,14 @@ dependencies:
56
98
  name: pry
57
99
  requirement: !ruby/object:Gem::Requirement
58
100
  requirements:
59
- - - ">"
101
+ - - "~>"
60
102
  - !ruby/object:Gem::Version
61
103
  version: '0.11'
62
104
  type: :development
63
105
  prerelease: false
64
106
  version_requirements: !ruby/object:Gem::Requirement
65
107
  requirements:
66
- - - ">"
108
+ - - "~>"
67
109
  - !ruby/object:Gem::Version
68
110
  version: '0.11'
69
111
  - !ruby/object:Gem::Dependency
@@ -126,34 +168,35 @@ dependencies:
126
168
  name: rubocop
127
169
  requirement: !ruby/object:Gem::Requirement
128
170
  requirements:
129
- - - ">"
171
+ - - "~>"
130
172
  - !ruby/object:Gem::Version
131
173
  version: '0.58'
132
174
  type: :development
133
175
  prerelease: false
134
176
  version_requirements: !ruby/object:Gem::Requirement
135
177
  requirements:
136
- - - ">"
178
+ - - "~>"
137
179
  - !ruby/object:Gem::Version
138
180
  version: '0.58'
139
181
  - !ruby/object:Gem::Dependency
140
182
  name: rubocop-rspec
141
183
  requirement: !ruby/object:Gem::Requirement
142
184
  requirements:
143
- - - ">"
185
+ - - "~>"
144
186
  - !ruby/object:Gem::Version
145
187
  version: '1.20'
146
188
  type: :development
147
189
  prerelease: false
148
190
  version_requirements: !ruby/object:Gem::Requirement
149
191
  requirements:
150
- - - ">"
192
+ - - "~>"
151
193
  - !ruby/object:Gem::Version
152
194
  version: '1.20'
153
195
  description: Client for working on HackerSchool projects
154
196
  email:
155
197
  - dimitri@hackerschool.ge
156
- executables: []
198
+ executables:
199
+ - hscli
157
200
  extensions: []
158
201
  extra_rdoc_files: []
159
202
  files:
@@ -168,13 +211,19 @@ files:
168
211
  - LICENSE.txt
169
212
  - README.md
170
213
  - Rakefile
214
+ - app/public/default.css
215
+ - app/views/_footer.erb
216
+ - app/views/_nav.erb
217
+ - app/views/chapter.erb
218
+ - app/views/course.erb
219
+ - app/views/layout.erb
171
220
  - bin/console
172
221
  - bin/setup
222
+ - exe/hscli
173
223
  - hs.gemspec
174
224
  - lib/hs.rb
175
- - lib/hs/chapter.rb
176
225
  - lib/hs/config.rb
177
- - lib/hs/course.rb
226
+ - lib/hs/devserver.rb
178
227
  - lib/hs/elements/br.rb
179
228
  - lib/hs/elements/code.rb
180
229
  - lib/hs/elements/dd.rb
@@ -199,6 +248,8 @@ files:
199
248
  - lib/hs/loaders/course_loader.rb
200
249
  - lib/hs/loaders/element_loader.rb
201
250
  - lib/hs/loaders/xml_parser.rb
251
+ - lib/hs/models/chapter.rb
252
+ - lib/hs/models/course.rb
202
253
  - lib/hs/preview/chapter_preview.rb
203
254
  - lib/hs/preview/course_preview.rb
204
255
  - lib/hs/preview/element_preview.rb
File without changes