nesta-contentfocus-extensions 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 31795688f9f78310de422e30b0ba26d3289ab0f3
4
+ data.tar.gz: 1f1f4cee9802c94ebb2307671573325dfa0ea919
5
+ SHA512:
6
+ metadata.gz: 2be3580c108d5e01f80c5758683fe2adc7a2825e2fe8dddb2331b15a30a22e380aabb2a81964c8b877d947fef00618be9f4165c5c1c2f0712111ea443eb4c632
7
+ data.tar.gz: 645aa04f8935ec555cc29fb0ef9a46a2ae27b19696f16f2b5948032f02a1567bbc3a28547e99afbec369ed2a4924185db596757cbcaed4b8501406ce866e4a7c
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Glu IO Pty Ltd, Glenn Gillen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # ContentFocus Extensions
2
+
3
+ ## Installation
4
+
5
+ ## Usage
6
+
7
+ ## Contributing
8
+
9
+ 1. Fork it ( https://github.com/gluio/nesta-plugin-contentfocus/fork )
10
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
11
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
12
+ 4. Push to the branch (`git push origin my-new-feature`)
13
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,4 @@
1
+ require "nesta-contentfocus-extensions/version"
2
+ require "nesta-contentfocus-extensions/menu"
3
+ require "nesta-contentfocus-extensions/page"
4
+ require "nesta-contentfocus-extensions/path"
@@ -0,0 +1,29 @@
1
+ require 'tempfile'
2
+ require 'nesta/models'
3
+
4
+ module Nesta
5
+ class Menu
6
+ class << self
7
+ alias_method :pre_contentfocus_full_menu, :full_menu
8
+ end
9
+
10
+ def self.full_menu
11
+ return @full_menu if @full_menu
12
+ @full_menu = pre_contentfocus_full_menu
13
+ if @full_menu.empty?
14
+ menu_file = Tempfile.new('menu')
15
+ Page.find_all.map(&:categories).flatten.compact.uniq.each do |category|
16
+ menu_file.write(category.abspath + "\n")
17
+ category.pages.each do |sub_category|
18
+ menu_file.write(Nesta::Menu::INDENT + sub_category.abspath + "\n")
19
+ end
20
+ end.flatten
21
+ menu_file.rewind
22
+ append_menu_item(@full_menu, menu_file, 0)
23
+ menu_file.close
24
+ menu_file.unlink
25
+ end
26
+ @full_menu
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,67 @@
1
+ require 'redcarpet'
2
+ require 'nesta/models'
3
+
4
+ module Nesta
5
+ module ContentFocus
6
+ class HTMLRenderer < Redcarpet::Render::HTML
7
+ def preprocess(document)
8
+ @document = document
9
+ end
10
+
11
+ def paragraph(content)
12
+ if ['[TOC]'].include?(content)
13
+ toc_render = Redcarpet::Render::HTML_TOC.new(nesting_level: 2)
14
+ parser = Redcarpet::Markdown.new(toc_render)
15
+ rendered = parser.render(@document)
16
+ rendered.sub!(/\A<ul>/, '<ul class="toc">')
17
+ return rendered
18
+ else
19
+ ["<p>",content,"</p>"].join
20
+ end
21
+ end
22
+
23
+ def block_quote(content)
24
+ if content.match(/\A<p>\.([a-z]+) /)
25
+ cssclass = $1
26
+ content.sub!(/\A\<p>.([a-z]+) /, "")
27
+ content.sub!(/<\/p>\z/, "")
28
+ [%Q{<div class="#{cssclass}"><p>}, content, "</p></div>"].join
29
+ else
30
+ ["<blockquote>", content, "</blockquote>"].join
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ module Nesta
38
+ class Page < FileModel
39
+ def convert_to_html(format, scope, text)
40
+ render_options = {
41
+ prettify: true,
42
+ safe_links_only: true,
43
+ with_toc_data: true
44
+ }
45
+ markdown_options = {
46
+ renderer: Nesta::ContentFocus::HTMLRenderer.new(render_options),
47
+ autolink: true,
48
+ disable_indented_code_blocks: true,
49
+ fenced_code_blocks: true,
50
+ footnotes: true,
51
+ highlight: true,
52
+ no_intra_emphasis: true,
53
+ quote: true,
54
+ strikethrough: true,
55
+ superscript: true,
56
+ tables: true
57
+ }
58
+ text = add_p_tags_to_haml(text) if @format == :haml
59
+ template = Tilt[format].new(nil, 1, markdown_options) { text }
60
+ template.render(scope)
61
+ end
62
+
63
+ def intro_image
64
+ return metadata('Intro Image') if metadata('Intro Image')
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,24 @@
1
+ require "nesta/path"
2
+
3
+ module Nesta
4
+ class Path
5
+ class << self
6
+ alias_method :pre_contentfocus_themes, :themes
7
+ end
8
+
9
+ def self.themes(*args)
10
+ theme = args[0]
11
+ if Nesta::Config.theme && Nesta::Theme.const_get(theme.capitalize) && theme_dir = resolve_theme_path(theme)
12
+ File.expand_path(File.join(*args[1..-1]), theme_dir + "/../..")
13
+ else
14
+ pre_contentfocus_themes(*args)
15
+ end
16
+ end
17
+
18
+ def self.resolve_theme_path(theme)
19
+ if path = $".grep(%r{nesta-theme-#{theme}\.rb})
20
+ path.first
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ module Nesta
2
+ module ContentFocus
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nesta-contentfocus-extensions/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nesta-contentfocus-extensions"
8
+ spec.version = Nesta::ContentFocus::VERSION
9
+ spec.authors = ["Glenn Gillen"]
10
+ spec.email = ["me@glenngillen.com"]
11
+ spec.summary = %q{A collection of extensions to the NestaCMS.}
12
+ spec.description = %q{Extensions to NestaCMS required to use ContentFocus or ContentFocus themes.}
13
+ spec.homepage = "https://contentfocus.io/"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_runtime_dependency 'nesta', '>= 0.11.0'
24
+ spec.add_runtime_dependency 'redcarpet', '~> 3.2.2'
25
+ spec.add_runtime_dependency 'tilt', '~> 1.4.0'
26
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nesta-contentfocus-extensions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Glenn Gillen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nesta
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.11.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.11.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: redcarpet
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.2.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.2.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: tilt
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.4.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.4.0
83
+ description: Extensions to NestaCMS required to use ContentFocus or ContentFocus themes.
84
+ email:
85
+ - me@glenngillen.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - Gemfile
91
+ - LICENSE.txt
92
+ - README.md
93
+ - Rakefile
94
+ - lib/nesta-contentfocus-extensions.rb
95
+ - lib/nesta-contentfocus-extensions/menu.rb
96
+ - lib/nesta-contentfocus-extensions/page.rb
97
+ - lib/nesta-contentfocus-extensions/path.rb
98
+ - lib/nesta-contentfocus-extensions/version.rb
99
+ - nesta-contentfocus-extensions.gemspec
100
+ homepage: https://contentfocus.io/
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.2.2
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: A collection of extensions to the NestaCMS.
124
+ test_files: []