administrate-field-markdown 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e1a426225c9bb4ef7fdb361817d1fb086f08837d
4
+ data.tar.gz: 31242bce19ba11e835569394e00ab69f0cfa8124
5
+ SHA512:
6
+ metadata.gz: ab95d2915b6ea61358326c66a560340a675e4b3ca31993550d28c0c1fa9668a014aa022a400b6d3f163cee454b9e38ce14a623a6b3c0b6fd71ca3041c3ab1731
7
+ data.tar.gz: fb9e2a3b8ab2c3df45983574f73fa05d76ec345eda47bd113e8c0acfa25e0515875124eda6f77809079f69aeacbc947f2842cc36ac30f9385810cb156868c2ab
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # Administrate::Field::Color
2
+
3
+ A plugin to handle colors in [Administrate].
4
+
5
+ [Administrate]: https://github.com/thoughtbot/administrate
@@ -0,0 +1,22 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ require "administrate/field/markdown"
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "administrate-field-markdown"
7
+ gem.version = Administrate::Field::Markdown::VERSION
8
+ gem.authors = ["Dan Barber"]
9
+ gem.email = ["hello@danbarber.me"]
10
+ gem.homepage = "https://github.com/danbee/administrate_field_markdown"
11
+ gem.summary = "Markdown field plugin for Administrate"
12
+ gem.description = gem.summary
13
+ gem.license = "MIT"
14
+
15
+ gem.require_paths = ["lib"]
16
+ gem.files = `git ls-files`.split("\n")
17
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+
19
+ gem.add_dependency "administrate", ">= 0.2.0.rc1", "< 0.3.0"
20
+ gem.add_dependency "rails", "~> 4.2"
21
+ gem.add_dependency "kramdown", "~> 1.10"
22
+ end
@@ -0,0 +1,6 @@
1
+ <div class="field-unit__label">
2
+ <%= f.label field.attribute %>
3
+ </div>
4
+ <div class="field-unit__field">
5
+ <%= f.text_area field.attribute %>
6
+ </div>
@@ -0,0 +1 @@
1
+ <%= field.truncate %>
@@ -0,0 +1 @@
1
+ <%= field.rendered.html_safe %>
@@ -0,0 +1,28 @@
1
+ require "administrate/field/base"
2
+ require "rails"
3
+ require "kramdown"
4
+
5
+ module Administrate
6
+ module Field
7
+ class Markdown < Administrate::Field::Base
8
+ VERSION = "0.0.1"
9
+
10
+ class Engine < ::Rails::Engine
11
+ end
12
+
13
+ def rendered
14
+ Kramdown::Document.new(data).to_html
15
+ end
16
+
17
+ def truncate
18
+ data.to_s[0...truncation_length]
19
+ end
20
+
21
+ private
22
+
23
+ def truncation_length
24
+ options.fetch(:truncate, 50)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+ require "administrate/field/markdown"
2
+
3
+ describe Administrate::Field::Markdown do
4
+ describe "#rendered" do
5
+ it "renders markdown to HTML" do
6
+ markdown = "This is some markdown to render"
7
+
8
+ page = :show
9
+ field = Administrate::Field::Markdown.new(:markdown, markdown, page)
10
+
11
+ expect(field.rendered).to eq("<p>This is some markdown to render</p>\n")
12
+ end
13
+ end
14
+
15
+ describe "#to_partial_path" do
16
+ it "returns a partial based on the page being rendered" do
17
+ page = :show
18
+ field = Administrate::Field::Markdown.new(:markdown, "", page)
19
+
20
+ path = field.to_partial_path
21
+
22
+ expect(path).to eq("/fields/markdown/#{page}")
23
+ end
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: administrate-field-markdown
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dan Barber
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: administrate
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.0.rc1
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 0.3.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.2.0.rc1
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 0.3.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: rails
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '4.2'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '4.2'
47
+ - !ruby/object:Gem::Dependency
48
+ name: kramdown
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.10'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.10'
61
+ description: Markdown field plugin for Administrate
62
+ email:
63
+ - hello@danbarber.me
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - README.md
69
+ - administrate-field-markdown.gemspec
70
+ - app/views/fields/markdown/_form.html.erb
71
+ - app/views/fields/markdown/_index.html.erb
72
+ - app/views/fields/markdown/_show.html.erb
73
+ - lib/administrate/field/markdown.rb
74
+ - spec/lib/administrate/field/markdown_spec.rb
75
+ homepage: https://github.com/danbee/administrate_field_markdown
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.5.1
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Markdown field plugin for Administrate
99
+ test_files:
100
+ - spec/lib/administrate/field/markdown_spec.rb
101
+ has_rdoc: