hs-cli 0.2.0 → 0.2.1

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: afc4b0f4d4ced43015bb231e2f1f5ac5f9718d894d05e5693f347b9a9a470265
4
- data.tar.gz: 5dc88339bbec902c7cc61dc2dfc91bb9c517ddf86de34c060f1ae866be960739
3
+ metadata.gz: 5f5b61dbf6876ef125d18da10041763efc1f2d883522e3bffe9d5a487524a634
4
+ data.tar.gz: e76752103f1bd400826e10677d2b030d7904a88a07cd2b50d11aa1c863b52967
5
5
  SHA512:
6
- metadata.gz: 7deedf1c8db3b2e0493ac7ff951a58e8f272f8a1519e6c3ff4f37a0df373e20f496458a5fff62ce7c2d6860bcde5a0d5c1bb7aec03fbaff6b4bed26ca9c810ac
7
- data.tar.gz: 1a8d255f8d7440554326e4d57859d4eae1409f21f700d5303aa23477c64548624808e28b3b9bf81ebd1a58542f65034c63d6252e0d5aa8e5198c886381fefe23
6
+ metadata.gz: 598de64c44b05b09577ec800c0ae43adc3f66a12e2b610b68d999f2e9c89bd9a7fa1ae355db1c3e33bd80399d055244d458ab8a4f9c0b3c776d3e57cc5e26ee0
7
+ data.tar.gz: a3c79733e95ed0f2ead8ac14f58e91cf75736b8f6e32050a93a2deb80e63635599269ef7604e080fcdea15d5e3f319216fd2b4f451112526da725d49a448a727
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hs-cli (0.2.0)
4
+ hs-cli (0.2.1)
5
5
  activesupport (~> 5.2)
6
6
  nokogiri (~> 1.8)
7
7
  rack-contrib (~> 2.0)
Binary file
@@ -3,18 +3,19 @@
3
3
  <h1>
4
4
  <%= @chapter.title %>
5
5
  </h1>
6
+ <p class="uk-text-<%= @chapter.review_color %>">
7
+ <span uk-icon="icon: <%= @chapter.review_icon %>"></span>
8
+ <%= @chapter.review_title %>
9
+ </p>
6
10
  </div>
7
11
 
8
-
9
-
10
12
  <%= erb :_nav, layout: false, locals: { course: @course.title, chapter: @chapter.title } %>
11
13
 
12
-
13
-
14
14
  <div class="uk-container">
15
15
  <%= @chapter.preview %>
16
16
  </div>
17
17
 
18
18
  <%= erb :_nav, layout: false, locals: { course: @course.title, chapter: @chapter.title } %>
19
+
19
20
  <%= erb :_footer, layout: false %>
20
21
  </div>
data/app/views/course.erb CHANGED
@@ -15,7 +15,8 @@
15
15
  <ol class="toc">
16
16
  <% @course.chapters.each do |chapter| %>
17
17
  <li>
18
- <a href="/<%= chapter.slug %>">
18
+ <a href="/<%= chapter.slug %>" class="uk-text-<%= chapter.review_color %>">
19
+ <span uk-icon="icon: <%= chapter.review_icon %>"></span>
19
20
  <%= chapter.title %>
20
21
  </a>
21
22
  </li>
data/lib/hs/devserver.rb CHANGED
@@ -9,7 +9,7 @@ module HS
9
9
  attr_accessor :app, :entry
10
10
 
11
11
  def create(config = {})
12
- self.entry = config[:entry] || 'content/course.xml'
12
+ self.entry = config[:entry]
13
13
  self.app = initialize_application(config)
14
14
  set_root_route
15
15
  set_chapter_route
@@ -21,9 +21,15 @@ module HS
21
21
  def initialize_application(config)
22
22
  public_folder = config[:public_folder] || 'public'
23
23
  hs_public_folder = File.expand_path('../../app/public', __dir__)
24
+ port = config[:port] || '8080'
25
+ bind = config[:bind] || '0.0.0.0'
26
+ create_application(public_folder, hs_public_folder, bind, port)
27
+ end
28
+
29
+ def create_application(public_folder, hs_public_folder, bind, port)
24
30
  Sinatra.new do
25
- set(:bind, '0.0.0.0')
26
- set(:port, 8080)
31
+ set(:bind, bind)
32
+ set(:port, port)
27
33
  set(:views, File.expand_path('../../app/views', __dir__))
28
34
  set(:public_folder, public_folder)
29
35
  use(Rack::TryStatic, root: hs_public_folder, urls: %w[/])
@@ -15,7 +15,11 @@ module HS
15
15
  private
16
16
 
17
17
  def create_chapter(course, data) # rubocop:disable Metrics/MethodLength
18
- chapter = HS::Chapter.new(course, slug: data[:slug])
18
+ chapter = HS::Chapter.new(
19
+ course,
20
+ slug: data[:slug],
21
+ review_status: data[:review_status]
22
+ )
19
23
 
20
24
  data[:_children].each do |child|
21
25
  case child[:_name]
@@ -8,12 +8,15 @@ module HS
8
8
  extend HS::ChapterLoader
9
9
  include HS::ChapterPreview
10
10
 
11
+ REVIEW_STATUSES = %w[none first second final].freeze
12
+
11
13
  def self.load(course, file)
12
14
  load_chapter(course, File.read(file))
13
15
  end
14
16
 
15
17
  attr_reader :course, :content
16
18
  attr_accessor :slug, :title, :intro
19
+ attr_writer :review_status
17
20
 
18
21
  def initialize(course, args)
19
22
  @course = course
@@ -24,6 +27,11 @@ module HS
24
27
  end
25
28
  end
26
29
 
30
+ def review_status
31
+ return 'none' unless REVIEW_STATUSES.include?(@review_status)
32
+ @review_status
33
+ end
34
+
27
35
  def hs_url
28
36
  "#{course.hs_url}/#{slug}"
29
37
  end
@@ -6,10 +6,43 @@ module HS
6
6
  module ChapterPreview
7
7
  include HS::HTMLPreview
8
8
 
9
+ REVIEW_ICON = {
10
+ none: 'file',
11
+ first: 'file-edit',
12
+ second: 'heart',
13
+ final: 'check'
14
+ }.freeze
15
+
16
+ REVIEW_COLOR = {
17
+ none: 'muted',
18
+ first: 'warning',
19
+ second: 'danger',
20
+ final: 'primary'
21
+ }.freeze
22
+
23
+ REVIEW_TITLE = {
24
+ none: 'არაა რედაქტირებული',
25
+ first: 'პირველადი რედაქტირება',
26
+ second: 'მეორადი რედაქტირება',
27
+ final: 'საბოლოო რედაქცია'
28
+ }.freeze
29
+
9
30
  def preview
10
31
  body_element
11
32
  end
12
33
 
34
+ def review_icon
35
+ REVIEW_ICON[review_status.to_sym]
36
+ end
37
+
38
+ def review_title
39
+ REVIEW_TITLE[review_status.to_sym]
40
+ end
41
+
42
+ def review_color
43
+ REVIEW_COLOR[review_status.to_sym]
44
+ end
45
+
13
46
  private
14
47
 
15
48
  def body_element
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.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
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.2.0
4
+ version: 0.2.1
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-23 00:00:00.000000000 Z
11
+ date: 2018-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -212,6 +212,7 @@ files:
212
212
  - README.md
213
213
  - Rakefile
214
214
  - app/public/default.css
215
+ - app/public/favicon.ico
215
216
  - app/views/_footer.erb
216
217
  - app/views/_nav.erb
217
218
  - app/views/chapter.erb