iris_rails 0.2.0 → 1.0.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: 1df0c03c62172f9afad270b4993a2d74d526bfdb8f472365b4c8bfebac261bb5
4
- data.tar.gz: e71e30515913579868fa114e3a69cd7555b9f6bd0a1dae3e66f879c4c0219eb4
3
+ metadata.gz: a73671f6aac8f0da411ff5bbda15d41e279a8a32e9b82f1efbe7dc4ed71fd0f6
4
+ data.tar.gz: 46e3ead0ed312e11d6c23960718937df7fe9310701f68f8acc5731caa5cfeecd
5
5
  SHA512:
6
- metadata.gz: be35175aa33470983499c8fea98e1bc343515368152d8d8b8a35060e98f1133f55b2b853d7c95e0d47212cc658271112c589046290e8874ea8948bd7302743c5
7
- data.tar.gz: 5e0a360077e625f1ca2e25950d3e2cf73469e5f59f478c1b3ff73b083541edfed135947d84c633f93be6514a3f4002f1913ec1c6cb5604038f232ac1e8c38bfb
6
+ metadata.gz: c6eef5aa751e58609a23f9d69b1993725531d01e0fec6f66a98169de38efe08c8ddb8520f36754f9a3416511fea7bfdebcd144269811f811faff050a99e3ec11
7
+ data.tar.gz: f46d33786a3aeb6a66a68d59cf7b6a896b1de1b6c3d701733058df7948b97decda0bc8497bdefc005a10ba01ac3866ab163b7677eecae09c187571e9441cc391
data/README.md CHANGED
@@ -9,32 +9,83 @@ TODO: Delete this and the text above, and describe your gem
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'iris-rails'
12
+ gem 'iris_rails'
13
13
  ```
14
14
 
15
15
  And then execute:
16
16
 
17
+ ```ruby
17
18
  $ bundle
19
+ ```
18
20
 
19
21
  Or install it yourself as:
20
22
 
21
- $ gem install iris
23
+ ```ruby
24
+ $ gem install iris_rails
25
+ ```
22
26
 
23
27
  ## Usage
24
28
 
25
- Or install it yourself as:
29
+ After installing, run the genereator provided by the gem:
30
+
31
+ ```ruby
32
+ rails generate iris:install
33
+ ```
34
+
35
+ The generator creates an initializer file and default controllers and views:
36
+
37
+ ```
38
+ |-- app
39
+ |-- controllers
40
+ |-- iris_rails
41
+ |-- base_controller.rb
42
+ |-- posts_controller.rb
43
+ |-- views
44
+ |-- iris_rails
45
+ |-- posts
46
+ |-- index.html.erb
47
+ |-- show.html.erb
48
+ |-- helpers
49
+ |-- meta_tags_helper.rb
50
+
51
+ |-- config
52
+ |-- initializers
53
+ |-- iris_rails.rb
54
+ |-- lib
55
+ |-- iris_rails.rb
56
+ ```
57
+
58
+ It also adds routes to your `routes.rb` file:
59
+
60
+ ```ruby
61
+ scope :module => 'iris_rails' do
62
+ get '/blog' => 'posts#index', :as => :iris_blog
63
+ get '/blog/:slug' => 'posts#show', :as => :iris_post
64
+ end
65
+ ```
66
+
67
+ After running the generator, set your API token in `config/initializers/iris_rails.rb`
26
68
 
27
- $ rails install:iris-rails
69
+ ## Customization
28
70
 
29
- ## Development
71
+ Extending and customizing your blog is easy.
72
+
73
+ Define in `app/controllers/iris_rails/base_controller.rb` the layout you will use. If you have some verifications the page, make sure to copy them to IrisRails::BaseController.
74
+
75
+ Iris_Rails uses a helper method to define title, meta tags (meta title, meta description and meta keywords) and use CSS with the template defined in iris website (iriseo.com). Make sure you select the template in iris.com/settings so your blog has a nice look! Add the lines below to the layout you will use and and set title and meta tags of your website.
76
+
77
+ ```ruby
78
+ iris_meta_tags(head_title: 'INSERT_WEBSITE_TITLE', meta_description: 'INSERT_WEBSITE_META_DESCRIPTION', meta_keywords: 'INSERT_WEBSITE_META_KEYWORDS', meta_author: 'INSERT_WEBSITE_META_AUTHOR')
79
+ ```
30
80
 
31
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
81
+ Insert your website title in INSERT_WEBSITE_TITLE, meta_description in INSERT_WEBSITE_META_DESCRIPTION, meta_keywords in INSERT_WEBSITE_META_KEYWORDS and meta_author in INSERT_WEBSITE_META_AUTHOR. Don't create a tag with these attributes if you are using the method iris_meta_tags because duplicated attributes lower the SEO score. If you don't have these attributes, just leave it as a whitespace.
32
82
 
33
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
83
+ Now start your server and to view your blog just access YOUR_URL/blog.
84
+ Reminder, you have to add posts to your blog in Iris website www.iriseo.com.
34
85
 
35
86
  ## Contributing
36
87
 
37
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/iris. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
88
+ Bug reports and pull requests are welcome on GitHub at https://github.com/horta-tech/iris-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
38
89
 
39
90
  ## License
40
91
 
@@ -42,4 +93,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
42
93
 
43
94
  ## Code of Conduct
44
95
 
45
- Everyone interacting in the Iris project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/iris/blob/master/CODE_OF_CONDUCT.md).
96
+ Everyone interacting in the Iris project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/horta-tech/iris-rails/blob/master/CODE_OF_CONDUCT.md).
data/bin/console CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  require "bundler/setup"
4
3
  require "iris"
5
4
 
@@ -28,7 +28,9 @@ Gem::Specification.new do |spec|
28
28
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ["lib"]
30
30
 
31
+ spec.add_runtime_dependency "rest-client", "~> 2.1.0"
32
+
31
33
  spec.add_development_dependency "bundler", "~> 2.0"
32
34
  spec.add_development_dependency "rake", "~> 13.0"
33
35
  spec.add_development_dependency "rspec", "~> 3.2"
34
- end
36
+ end
@@ -17,7 +17,10 @@ module Iris
17
17
  directory "app/views/iris_rails", "app/views/iris_rails"
18
18
 
19
19
  # Create helper
20
- directory "app/helpers/meta_tags_helper", "app/helpers/meta_tags_helper"
20
+ copy_file "app/helpers/meta_tags_helper.rb", "app/helpers/meta_tags_helper.rb"
21
+
22
+ # Create iris_rails model
23
+ copy_file "../lib/iris_rails.rb", "lib/iris_rails.rb"
21
24
 
22
25
  # Create default layout
23
26
  # directory "app/views/layouts/iris", "app/views/layouts/iris"
File without changes
@@ -1,4 +1,5 @@
1
1
  class IrisRails::BaseController < ActionController::Base
2
2
  # If you want, you can set a different layout for your blog here
3
- # layout 'example'
3
+ layout 'application'
4
+ # Add your verifications here if your layout uses any
4
5
  end
@@ -6,20 +6,31 @@ class IrisRails::PostsController < IrisRails::BaseController
6
6
  @first_posts = @posts.first(3)
7
7
  @highlighted_posts = @posts[3, 3]
8
8
  @more_posts = @posts[6, @posts.size - (@posts.length.odd? ? 9 : 6)]
9
- @last_posts = @posts.length.odd? ? @posts.last(3) : []
9
+ if @posts.length.odd? && (@posts.length >= 9)
10
+ @last_posts = @posts.last(3)
11
+ elsif @posts.length == 7
12
+ @last_posts = []
13
+ @last_posts << @posts.last
14
+ end
10
15
  end
11
16
 
12
17
  def show
13
18
  response = IrisRails::Post.find(params[:slug])
14
19
  @post, @related_posts, @account = response
15
20
  @author = author_name_or_email(@post.author)
21
+ strongkeyphrase = '<strong>' + @post.keyphrase + '</strong>'
22
+ @post.first_introduction = @post.first_introduction.gsub(@post.keyphrase, strongkeyphrase)
23
+ @post.second_introduction = @post.second_introduction.gsub(@post.keyphrase, strongkeyphrase)
24
+ @post.ordered_topics.each do |topic|
25
+ topic['content'] = topic['content'].gsub(@post.keyphrase, strongkeyphrase)
26
+ end
16
27
  end
17
28
 
18
29
  private
19
30
 
20
31
  def author_name_or_email(author)
21
32
  if author['first_name'] || author['last_name']
22
- "#{author['first_name'] } #{author['last_name'] }"
33
+ "#{author['first_name'].strip} #{author['last_name'].strip}"
23
34
  else
24
35
  author['email']
25
36
  end
@@ -4,25 +4,35 @@ module MetaTagsHelper
4
4
  set_title(meta_tags[:head_title]),
5
5
  meta_title(meta_tags[:head_title]),
6
6
  meta_description(meta_tags[:meta_description]),
7
- meta_keywords(meta_tags[:meta_keywords])
7
+ meta_keywords(meta_tags[:meta_keywords]),
8
+ meta_author(meta_tags[:meta_author]),
9
+ set_iris_css
8
10
  ].join("\n").html_safe
9
11
  end
10
12
 
11
13
  private
12
14
 
13
15
  def set_title(given_title)
14
- content_for?(:title) ? content_tag(:title, 'Iris | ' + content_for(:title)) : (content_tag(:title, given_title) if !given_title.empty?)
16
+ content_for?(:title) ? content_tag(:title, content_for(:account_name) + ' | ' + content_for(:title)) : (content_tag(:title, given_title) if !given_title.nil?)
15
17
  end
16
18
 
17
19
  def meta_title(given_meta_title)
18
- content_for?(:title) ? tag('meta', :name => 'title', :content => content_for(:title)) : (tag('meta', :name => 'title', :content => given_meta_title) if !given_meta_title.empty?)
20
+ content_for?(:title) ? tag('meta', name: 'title', :content => content_for(:title)) : (tag('meta', :name => 'title', :content => given_meta_title) if !given_meta_title.nil?)
19
21
  end
20
22
 
21
23
  def meta_description(given_meta_description)
22
- content_for?(:meta_description) ? tag('meta', :name => 'description', :content => content_for(:meta_description)) : (tag('meta', :name => 'description', :content => given_meta_description) if !given_meta_description.empty?)
24
+ content_for?(:meta_description) ? tag('meta', name: 'description', :content => content_for(:meta_description)) : (tag('meta', :name => 'description', :content => given_meta_description) if !given_meta_description.nil?)
23
25
  end
24
26
 
25
27
  def meta_keywords(given_meta_keywords)
26
- content_for?(:meta_keywords) ? tag('meta', :name => 'keywords', :content => content_for(:meta_keywords)) : (tag('meta', :name => 'keywords', :content => given_meta_keywords) if !given_meta_keywords.empty?)
28
+ content_for?(:meta_keywords) ? tag('meta', name: 'keywords', :content => content_for(:meta_keywords)) : (tag('meta', :name => 'keywords', :content => given_meta_keywords) if !given_meta_keywords.nil?)
29
+ end
30
+
31
+ def meta_author(given_meta_author)
32
+ content_for?(:meta_author) ? tag('meta', name: 'author', :content => content_for(:meta_author)) : (tag('meta', :name => 'author', :content => given_meta_author) if !given_meta_author.nil?)
33
+ end
34
+
35
+ def set_iris_css
36
+ tag(:link, href: "https://cdn.jsdelivr.net/npm/iris-cms/templates/#{content_for(:iris_css)}.css", rel: 'stylesheet') if content_for?(:iris_css)
27
37
  end
28
38
  end
@@ -1,6 +1,8 @@
1
- <% content_for :title, @account.account_title %>
2
- <% content_for :meta_description, @account.account_description %>
3
- <% content_for :meta_keywords, @account.account_keyword %>
1
+ <% content_for :title, @account.account_title
2
+ content_for :account_name, @account.account_name
3
+ content_for :meta_description, @account.account_description
4
+ content_for :meta_keywords, @account.account_keyword
5
+ content_for :iris_css, @account.template %>
4
6
 
5
7
  <div id="blog">
6
8
  <div id="iris-main-container">
@@ -9,7 +11,7 @@
9
11
  <h1 class="sub-title"><%= @account.account_name %></h1>
10
12
  </div>
11
13
  <div class="blog_grid">
12
- <% @first_posts.each do |post| %>
14
+ <% @first_posts&.each do |post| %>
13
15
  <a href='<%= "/blog/#{post.slug}" %> '>
14
16
  <div class="post-div" style="background-image: url(<%= post.banner_image['url'] %>);">
15
17
  <div class="banner-info">
@@ -24,56 +26,60 @@
24
26
  </div>
25
27
  </section>
26
28
  <section>
27
- <div class="sub-title-div">
28
- <h2 class="sub-title">EM DESTAQUE</h2>
29
- </div>
30
- <div class="highlighted-posts">
31
- <% @highlighted_posts.each do |post| %>
32
- <a href='<%= "/blog/#{post.slug}" %> '>
33
- <div class="post-div" style="background-image: url(<%= post.banner_image['url'] %>);">
34
- <div class="banner-info">
35
- <p class="updatedinfo">Atualizado em <%= post.updated_at.to_time.strftime '%e/%m/%Y' %></p>
36
- <hr>
37
- <h3><%= post.main_title %></h3>
29
+ <% if @highlighted_posts %>
30
+ <div class="sub-title-div">
31
+ <h2 class="sub-title">EM DESTAQUE</h2>
32
+ </div>
33
+ <div class="highlighted-posts">
34
+ <% @highlighted_posts.each do |post| %>
35
+ <a href='<%= "/blog/#{post.slug}" %> '>
36
+ <div class="post-div" style="background-image: url(<%= post.banner_image['url'] %>);">
37
+ <div class="banner-info">
38
+ <p class="updatedinfo">Atualizado em <%= post.updated_at.to_time.strftime '%e/%m/%Y' %></p>
39
+ <hr>
40
+ <h3><%= post.main_title %></h3>
41
+ </div>
38
42
  </div>
39
- </div>
40
- <p class="description"><%= post.secondary_title %></p>
41
- </a>
42
- <% end %>
43
- </div>
43
+ <p class="description"><%= post.secondary_title %></p>
44
+ </a>
45
+ <% end %>
46
+ </div>
47
+ <% end %>
44
48
  </section>
45
49
  <section>
46
- <div class="sub-title-div">
47
- <h2 class="sub-title">MAIS NOTÍCIAS</h2>
48
- </div>
49
- <div class="more-posts">
50
- <% @more_posts.each do |post| %>
51
- <a href='<%= "/blog/#{post.slug}" %> '>
52
- <div class="post-div" style="background-image: url(<%= post.banner_image['url'] %>);">
53
- <div class="banner-info">
54
- <p class="updatedinfo">Atualizado em <%= post.updated_at.to_time.strftime '%e/%m/%Y' %></p>
55
- <hr>
56
- <h3><%= post.main_title %></h3>
50
+ <% if @more_posts || @last_posts %>
51
+ <div class="sub-title-div">
52
+ <h2 class="sub-title">MAIS NOTÍCIAS</h2>
53
+ </div>
54
+ <div class="more-posts">
55
+ <% @more_posts&.each do |post| %>
56
+ <a href='<%= "/blog/#{post.slug}" %> '>
57
+ <div class="post-div" style="background-image: url(<%= post.banner_image['url'] %>);">
58
+ <div class="banner-info">
59
+ <p class="updatedinfo">Atualizado em <%= post.updated_at.to_time.strftime '%e/%m/%Y' %></p>
60
+ <hr>
61
+ <h3><%= post.main_title %></h3>
62
+ </div>
57
63
  </div>
58
- </div>
59
- <p class="description"><%= post.secondary_title %></p>
60
- </a>
61
- <% end %>
62
- </div>
63
- <div class="last-three-posts">
64
- <% @last_posts.each do |post| %>
65
- <a href='<%= "/blog/#{post.slug}" %> '>
66
- <div class="post-div" style="background-image: url(<%= post.banner_image['url'] %>);">
67
- <div class="banner-info">
68
- <p class="updatedinfo">Atualizado em <%= post.updated_at.to_time.strftime '%e/%m/%Y' %></p>
69
- <hr>
70
- <h3><%= post.main_title %></h3>
64
+ <p class="description"><%= post.secondary_title %></p>
65
+ </a>
66
+ <% end %>
67
+ </div>
68
+ <div class="last-three-posts">
69
+ <% @last_posts&.each do |post| %>
70
+ <a href='<%= "/blog/#{post.slug}" %> '>
71
+ <div class="post-div" style="background-image: url(<%= post.banner_image['url'] %>);">
72
+ <div class="banner-info">
73
+ <p class="updatedinfo">Atualizado em <%= post.updated_at.to_time.strftime '%e/%m/%Y' %></p>
74
+ <hr>
75
+ <h3><%= post.main_title %></h3>
76
+ </div>
71
77
  </div>
72
- </div>
73
- <p class="description"><%= post.secondary_title %></p>
74
- </a>
75
- <% end %>
76
- </div>
78
+ <p class="description"><%= post.secondary_title %></p>
79
+ </a>
80
+ <% end %>
81
+ </div>
82
+ <% end %>
77
83
  </section>
78
84
  </div>
79
85
  </div>
@@ -1,6 +1,9 @@
1
- <% content_for :title, @post.main_title %>
2
- <% content_for :meta_description, @post.meta_description %>
3
- <% content_for :meta_keywords, @post.keyphrase %>
1
+ <% content_for :title, @post.main_title
2
+ content_for :account_name, @account.account_name
3
+ content_for :meta_description, @post.meta_description
4
+ content_for :meta_keywords, @post.keyphrase
5
+ content_for :meta_author, @author
6
+ content_for :iris_css, @account.template %>
4
7
 
5
8
  <main id="blog" style="opacity: 1; transition: all 1s ease 0s;">
6
9
  <article id="iris-main-container">
@@ -1,2 +1,2 @@
1
- require 'iris-rails'
1
+ require 'iris_rails'
2
2
  IrisRails::api_token = ENV['IRIS_TOKEN']
data/lib/iris/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Iris
2
- VERSION = "0.2.0"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iris_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rayan Castro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-31 00:00:00.000000000 Z
11
+ date: 2020-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -70,15 +84,15 @@ files:
70
84
  - Rakefile
71
85
  - bin/console
72
86
  - bin/setup
73
- - iris.gemspec
87
+ - iris_rails.gemspec
74
88
  - lib/generators/iris/install_generator.rb
89
+ - lib/generators/lib/iris_rails.rb
75
90
  - lib/generators/templates/app/controllers/iris_rails/base_controller.rb
76
91
  - lib/generators/templates/app/controllers/iris_rails/posts_controller.rb
77
92
  - lib/generators/templates/app/helpers/meta_tags_helper.rb
78
93
  - lib/generators/templates/app/views/iris_rails/posts/index.html.erb
79
94
  - lib/generators/templates/app/views/iris_rails/posts/show.html.erb
80
95
  - lib/generators/templates/config/initializers/iris_rails.rb
81
- - lib/iris-rails.rb
82
96
  - lib/iris/version.rb
83
97
  homepage: https://github.com/horta-tech/iris-rails
84
98
  licenses: