brightguide 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 852e65dd848322bb0b21c7fc3dd8a6055b54bcd3
4
+ data.tar.gz: f078001bb09ee168cf38dc57c2c953d89e219604
5
+ SHA512:
6
+ metadata.gz: 5f8ac0c6495ddded9b83b990e6e44feef97dc5d2cab5c9c8a04ff312bad0fc710fc29fed60d990255387274d151a7ce729012596877f2a3118d84edb5db0d765
7
+ data.tar.gz: ef105de512f753d8aa06c8e38b8a920e9b0dc3530424cb38675913d89ed25ddbbba9c0f2ccaeae8b186e8c6a8d85bd52227b323af6ab20fbed94b264362dd1f2
@@ -0,0 +1,116 @@
1
+ $font: -apple-system, BlinkMacSystemFont, sans-serif;
2
+
3
+ .styleguide-body {
4
+ background: #f3f5f7;
5
+ color: #444;
6
+ }
7
+
8
+ .styleguide-content {
9
+ max-width: 700px;
10
+ margin: auto;
11
+ }
12
+
13
+ .styleguide-heading {
14
+ font-size: 36px;
15
+ margin-top: 30px;
16
+ margin-bottom: 40px;
17
+ font-weight: 600;
18
+ color: #111;
19
+ font-family: $font;
20
+ }
21
+
22
+ h1 {
23
+ font-size: 28px;
24
+ font-weight: 600;
25
+ color: #111;
26
+ font-family: $font;
27
+ }
28
+
29
+ h2 {
30
+ font-size: 18px;
31
+ font-weight: 600;
32
+ margin-bottom: 0.5em;
33
+ color: #111;
34
+ font-family: $font;
35
+ }
36
+
37
+ p {
38
+ font-family: $font;
39
+ margin-bottom: 1em;
40
+ &:last-child {
41
+ margin-bottom: 0;
42
+ }
43
+ }
44
+
45
+ .styleguide-card {
46
+ background: #fff;
47
+ border-radius: 5px;
48
+ margin-bottom: 30px;
49
+ }
50
+
51
+ .styleguide-card-heading {
52
+ padding: 30px;
53
+ border-bottom: 2px solid #f3f5f7;
54
+ }
55
+
56
+ .styleguide-card-section {
57
+ padding: 30px;
58
+ & + & {
59
+ border-top: 2px solid #f3f5f7;
60
+ }
61
+ }
62
+
63
+
64
+ hr {
65
+ margin: 1em 0;
66
+ height: 1px;
67
+ border: 0;
68
+ background: #f3f5f7;
69
+ }
70
+
71
+ .styleguide-example {
72
+ border: 3px solid #f3f5f7;
73
+ margin-bottom: 1em;
74
+
75
+ > div {
76
+ padding: 20px;
77
+ overflow: hidden;
78
+ }
79
+
80
+ > pre {
81
+ padding: 20px;
82
+ background: #f3f5f7;
83
+ font: 14px / 18px Menlo, Monaco, monospace;
84
+ overflow-y: auto;
85
+ }
86
+ &:last-child {
87
+ margin-bottom: 0;
88
+ }
89
+ }
90
+
91
+ .styleguide-card-folder {
92
+ font-family: $font;
93
+ color: #97a3a9;
94
+ float: right;
95
+ }
96
+
97
+ code {
98
+ font: 14px / 14px Menlo, Monaco, monospace;
99
+ background: #f3f5f7;
100
+ color: #096eda;
101
+ display: inline-block;
102
+ padding: 4px;
103
+ }
104
+
105
+ .example-square {
106
+ background: #24b198;
107
+ width: 50px;
108
+ height: 50px;
109
+ line-height: 50px;
110
+ }
111
+
112
+ .example-square-2 {
113
+ width: 100%;
114
+ height: 100%;
115
+ background: #154eb5;
116
+ }
@@ -0,0 +1,5 @@
1
+ module Brightguide
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ require_dependency "brightguide/application_controller"
2
+ require_dependency "brightguide/markdown_helper"
3
+
4
+ module Brightguide
5
+ class CardsController < ApplicationController
6
+ def index
7
+ @cards = Card.all
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,24 @@
1
+ module Brightguide
2
+ module MarkdownHelper
3
+ def render_markdown(str)
4
+ markdown_renderer.render(str).html_safe
5
+ end
6
+
7
+ private
8
+
9
+ def markdown_renderer
10
+ @markdown_renderer = Redcarpet::Markdown.new(StyleguideRenderer)
11
+ end
12
+
13
+ class StyleguideRenderer < Redcarpet::Render::HTML
14
+ def block_code(code, _language)
15
+ <<EOS
16
+ <div class="styleguide-example">
17
+ <div>#{code}</div>
18
+ <pre>#{CGI.escapeHTML(code).gsub("\n", '&#x000A;')}</pre>
19
+ </div>
20
+ EOS
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ module Brightguide
2
+ class Card
3
+ attr_reader :name, :sections, :folder_name
4
+ delegate :present?, to: :sections
5
+
6
+ def self.all
7
+ Brightguide::Parser.all.map { |item| new(item) }.select(&:present?)
8
+ end
9
+
10
+ def initialize(name:, sections:, folder_name:)
11
+ @name = name
12
+ @sections = sections
13
+ @folder_name = folder_name
14
+ end
15
+
16
+ def to_partial_path
17
+ "brightguide/cards/card"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ <div class="styleguide-card">
2
+ <div class="styleguide-card-heading">
3
+ <div class="styleguide-card-folder"><%= card.folder_name %></div>
4
+ <h1><%= card.name %></h1>
5
+ </div>
6
+ <% card.sections.each do |section| %>
7
+ <div class="styleguide-card-section">
8
+ <%= render_markdown(section) %>
9
+ </div>
10
+ <% end %>
11
+ </div>
@@ -0,0 +1 @@
1
+ <%= render @cards %>
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='utf-8'>
5
+ <meta content='width=device-width, initial-scale=1, maximum-scale=1.0' name='viewport'>
6
+ <title>Styleguide</title>
7
+ <%= csrf_meta_tags %>
8
+ <%= stylesheet_link_tag Brightguide.stylesheet_location %>
9
+
10
+ <%= stylesheet_link_tag 'brightguide/application' %>
11
+ <%= javascript_include_tag 'brightguide/application' %>
12
+ </head>
13
+ <body class="styleguide-body">
14
+ <div class="styleguide-content">
15
+ <h1 class="styleguide-heading">Styleguide</h1>
16
+ <%= yield %>
17
+ </div>
18
+ </body>
19
+ </html>
@@ -0,0 +1,3 @@
1
+ Brightguide::Engine.routes.draw do
2
+ root 'cards#index'
3
+ end
@@ -0,0 +1,15 @@
1
+ require "redcarpet"
2
+ require "brightguide/engine"
3
+ require "brightguide/parser"
4
+
5
+ module Brightguide
6
+ mattr_accessor :stylesheet_location
7
+ @@stylesheet_location = "application"
8
+
9
+ mattr_accessor :stylesheets_path
10
+ @@stylesheets_path = "app/assets/stylesheets"
11
+
12
+ def self.setup
13
+ yield self
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ module Brightguide
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Brightguide
4
+
5
+ initializer "Precompile hook", group: :all do |app|
6
+ app.config.assets.precompile += ["brightguide/application.css", "brightguide/application.js"]
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,39 @@
1
+ module Brightguide
2
+ module Parser
3
+ def self.all
4
+ file_paths.map do |file_path|
5
+ {
6
+ name: File.basename(file_path, ".*"),
7
+ sections: parse_file(file_path),
8
+ folder_name: folder_name(file_path)
9
+ }
10
+ end
11
+ end
12
+
13
+ def self.file_paths
14
+ Dir.glob(Rails.root.join(Brightguide.stylesheets_path, "**", "*")).select do |path|
15
+ File.file?(path)
16
+ end
17
+ end
18
+
19
+ def self.folder_name(file_path)
20
+ File.dirname(file_path).remove("#{Rails.root.join(Brightguide.stylesheets_path)}/")
21
+ end
22
+
23
+ def self.parse_file(file_path)
24
+ [].tap do |result|
25
+ File.open(file_path, "r") do |file|
26
+ documentation = false
27
+ file.each_line do |line|
28
+ documentation = false if line.starts_with?("*/")
29
+ result.last << line if documentation
30
+ if line.starts_with?("/* doc")
31
+ documentation = true
32
+ result << ""
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: brightguide
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Brightin developers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: redcarpet
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 3.3.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 3.3.4
27
+ description: Parses your styleguides and automatically creates styleguides.
28
+ email:
29
+ - hello@brightin.nl
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - app/assets/javascripts/brightguide/application.js
35
+ - app/assets/stylesheets/brightguide/application.scss
36
+ - app/controllers/brightguide/application_controller.rb
37
+ - app/controllers/brightguide/cards_controller.rb
38
+ - app/helpers/brightguide/markdown_helper.rb
39
+ - app/models/brightguide/card.rb
40
+ - app/views/brightguide/cards/_card.html.erb
41
+ - app/views/brightguide/cards/index.html.erb
42
+ - app/views/layouts/brightguide/application.html.erb
43
+ - config/routes.rb
44
+ - lib/brightguide.rb
45
+ - lib/brightguide/engine.rb
46
+ - lib/brightguide/parser.rb
47
+ homepage: http://www.brightin.nl
48
+ licenses: []
49
+ metadata: {}
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 2.6.4
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: Automatically created CSS styleguide.
70
+ test_files: []