iris_rails 0.1.0

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
+ SHA256:
3
+ metadata.gz: b4100391debced804f56a895f2b46e8cc43d1290a1d7387c2903ac80a7bf34c1
4
+ data.tar.gz: 7d124918eb097760bf10c3daa988c2aab173da105b32c237f9739b12401ce3a4
5
+ SHA512:
6
+ metadata.gz: af132d7acc89478f68fdaff422b88d66f0fe4b9fba7c88f81874765286fee06492750be6a3a329b29d40b377b20174c81d810edd1ba110b7c457284dce59a2f3
7
+ data.tar.gz: '09e33f09239943a90b47a807d33b7cb273bb7cd12cbbc904d63e863fcb03c9a35c5314306dc39b8c489e629ef891f3b856b5a5e75848f313c83951bd2a474432'
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.5
7
+ before_install: gem install bundler -v 2.0.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at rayancdc@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in iris.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ iris (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ rake (13.0.1)
11
+ rspec (3.9.0)
12
+ rspec-core (~> 3.9.0)
13
+ rspec-expectations (~> 3.9.0)
14
+ rspec-mocks (~> 3.9.0)
15
+ rspec-core (3.9.1)
16
+ rspec-support (~> 3.9.1)
17
+ rspec-expectations (3.9.0)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.9.0)
20
+ rspec-mocks (3.9.1)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.9.0)
23
+ rspec-support (3.9.2)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 2.0)
30
+ iris!
31
+ rake (~> 13.0)
32
+ rspec (~> 3.2)
33
+
34
+ BUNDLED WITH
35
+ 2.0.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Rayan Castro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Iris
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/iris`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'iris'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install iris
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ 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.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ 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).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "iris"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/iris.gemspec ADDED
@@ -0,0 +1,34 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "iris/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "iris_rails"
7
+ spec.version = Iris::VERSION
8
+ spec.authors = ["Rayan Castro"]
9
+ spec.email = ["rayancdc@gmail.com"]
10
+
11
+ spec.summary = "Easily render your iris blog server-side"
12
+ spec.description = "Easily render your iris blog server-side"
13
+ spec.homepage = "https://github.com/horta-tech/iris-rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.metadata["allowed_push_host"] = "https://rubygems.org/"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/horta-tech/iris-rails"
20
+ spec.metadata["changelog_uri"] = "https://github.com/horta-tech/iris-rails"
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 2.0"
32
+ spec.add_development_dependency "rake", "~> 13.0"
33
+ spec.add_development_dependency "rspec", "~> 3.2"
34
+ end
@@ -0,0 +1,37 @@
1
+ require 'rails/generators/base'
2
+
3
+ module Iris
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("../../templates", __FILE__)
7
+
8
+ desc "Creates iris initializer, controllers, views, and routes."
9
+ def install
10
+ # Create initializer
11
+ copy_file "config/initializers/iris_rails.rb", "config/initializers/iris_rails.rb"
12
+
13
+ # Create controllers
14
+ directory "app/controllers/iris_rails", "app/controllers/iris_rails"
15
+
16
+ # Create views
17
+ directory "app/views/iris_rails", "app/views/iris_rails"
18
+
19
+ # Create helper
20
+ directory "app/helpers/meta_tags_helper", "app/helpers/meta_tags_helper"
21
+
22
+ # Create default layout
23
+ # directory "app/views/layouts/iris", "app/views/layouts/iris"
24
+
25
+ # Add routes
26
+ route %{
27
+ scope :module => 'iris_rails' do
28
+ get '/blog' => 'posts#index', :as => :iris_blog
29
+ get '/blog/:slug' => 'posts#show', :as => :iris_post
30
+ end
31
+ }
32
+
33
+ puts "Success! Configure your API token in config/initializers/iris_rails.rb, restart your server, and view your blog at /blog"
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,4 @@
1
+ class IrisRails::BaseController < ActionController::Base
2
+ # If you want, you can set a different layout for your blog here
3
+ # layout 'example'
4
+ end
@@ -0,0 +1,27 @@
1
+ class IrisRails::PostsController < IrisRails::BaseController
2
+ def index
3
+ response = IrisRails::Post.all
4
+ @posts, @account = response
5
+
6
+ @first_posts = @posts.first(3)
7
+ @highlighted_posts = @posts[3, 3]
8
+ @more_posts = @posts[6, @posts.size - (@posts.length.odd? ? 9 : 6)]
9
+ @last_posts = @posts.length.odd? ? @posts.last(3) : []
10
+ end
11
+
12
+ def show
13
+ response = IrisRails::Post.find(params[:slug])
14
+ @post, @related_posts, @account = response
15
+ @author = author_name_or_email(@post.author)
16
+ end
17
+
18
+ private
19
+
20
+ def author_name_or_email(author)
21
+ if author['first_name'] || author['last_name']
22
+ "#{author['first_name'] } #{author['last_name'] }"
23
+ else
24
+ author['email']
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,28 @@
1
+ module MetaTagsHelper
2
+ def iris_meta_tags(meta_tags = {})
3
+ [
4
+ set_title(meta_tags[:head_title]),
5
+ meta_title(meta_tags[:head_title]),
6
+ meta_description(meta_tags[:meta_description]),
7
+ meta_keywords(meta_tags[:meta_keywords])
8
+ ].join("\n").html_safe
9
+ end
10
+
11
+ private
12
+
13
+ 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?)
15
+ end
16
+
17
+ 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?)
19
+ end
20
+
21
+ 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?)
23
+ end
24
+
25
+ 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?)
27
+ end
28
+ end
@@ -0,0 +1,79 @@
1
+ <% content_for :title, @account.account_title %>
2
+ <% content_for :meta_description, @account.account_description %>
3
+ <% content_for :meta_keywords, @account.account_keyword %>
4
+
5
+ <div id="blog">
6
+ <div id="iris-main-container">
7
+ <section>
8
+ <div class="sub-title-div">
9
+ <h1 class="sub-title"><%= @account.account_name %></h1>
10
+ </div>
11
+ <div class="blog_grid">
12
+ <% @first_posts.each do |post| %>
13
+ <a href='<%= "/blog/#{post.slug}" %> '>
14
+ <div class="post-div" style="background-image: url(<%= post.banner_image['url'] %>);">
15
+ <div class="banner-info">
16
+ <p class="updatedinfo">Atualizado em <%= post.updated_at.to_time.strftime '%e/%m/%Y' %></p>
17
+ <hr>
18
+ <h3><%= post.main_title %></h3>
19
+ </div>
20
+ </div>
21
+ <p class="description"><%= post.secondary_title %></p>
22
+ </a>
23
+ <% end %>
24
+ </div>
25
+ </section>
26
+ <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>
38
+ </div>
39
+ </div>
40
+ <p class="description"><%= post.secondary_title %></p>
41
+ </a>
42
+ <% end %>
43
+ </div>
44
+ </section>
45
+ <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>
57
+ </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>
71
+ </div>
72
+ </div>
73
+ <p class="description"><%= post.secondary_title %></p>
74
+ </a>
75
+ <% end %>
76
+ </div>
77
+ </section>
78
+ </div>
79
+ </div>
@@ -0,0 +1,93 @@
1
+ <% content_for :title, @post.main_title %>
2
+ <% content_for :meta_description, @post.meta_description %>
3
+ <% content_for :meta_keywords, @post.keyphrase %>
4
+
5
+ <main id="blog" style="opacity: 1; transition: all 1s ease 0s;">
6
+ <article id="iris-main-container">
7
+ <header class="post_banner">
8
+ <img src=<%= @post.banner_image['url'] %> alt='<%= "#{@account.account_name} | #{@post.keyphrase} | #{@post.main_title}" %>' class="banner_background"/>
9
+ <div class="banner_content">
10
+ <div class="author-and-description">
11
+ <p>Publicado por <%= @author %></p>
12
+ <p>Atualizado em <%= @post.updated_at.to_time.strftime '%e/%m/%Y %r' %></p>
13
+ </div>
14
+ <hr>
15
+ <h1 class="main_title"><%= @post.main_title %></h1>
16
+ <p class="banner_text"><%= @post.banner_text %></p>
17
+ </div>
18
+ </header>
19
+ <div class="post-grid">
20
+ <section class="post-wrapper">
21
+ <div class="introduction">
22
+ <h2 class="secondary_title"><%= @post.secondary_title %></h2>
23
+ <p class="first_introduction"><%= @post.first_introduction.gsub(/div/, 'span').html_safe %></p>
24
+ <ul class="internal_links_list">
25
+ <% @post.internal_links.each do |internal_link| %>
26
+ <li class="internal_links_item">
27
+ <a class="internal_link" target="_blank" href=<%= internal_link['url'].html_safe %> ><%= internal_link['text'].html_safe %></a>
28
+ </li>
29
+ <% end %>
30
+ </ul>
31
+ <p class="second_introduction"><%= @post.second_introduction.gsub(/div/, 'span').html_safe %></p>
32
+ </div>
33
+ <div class="topics">
34
+ <% @post.ordered_topics.each do |topic| %>
35
+ <div class="topic">
36
+ <% if topic['image']['url'] %>
37
+ <img class="topic_image" src="<%= topic['image']['url'] %>"
38
+ <% if topic['label'] %>
39
+ alt="<%= topic['label'] %>"
40
+ <% else %>
41
+ alt="<%= topic['image']['url'].split(/\/|\./)[-2] %>"
42
+ <% end %>
43
+ title='<%= topic['image']['url'].split(/\/|\./)[-2] %>'
44
+ />
45
+ <% end %>
46
+ <% if topic['label'] %>
47
+ <p class="image-label"><%= render html: topic['label'].html_safe %></p>
48
+ <% end %>
49
+ <% if topic['title'] %>
50
+ <h3 class="topic_title"><%= topic['title'] %></h3>
51
+ <% end %>
52
+ <p class="topic_content"><%= topic['content'].gsub(/div/, 'span').html_safe %></p>
53
+ </div>
54
+ <% end %>
55
+ </div>
56
+ <% if @post.call_to_action_content %>
57
+ <div class="call-to-action">
58
+ <div class="cta-wrapper">
59
+ <p class="cta_content"><%= @post.call_to_action_content.html_safe %></p>
60
+ <a class="cta-link" href="<%= @post.call_to_action_link %>">
61
+ <button class="cta-button">
62
+ <%= @post.call_to_action_link_description %>
63
+ </button>
64
+ </a>
65
+ </div>
66
+ </div>
67
+ <% end %>
68
+ <% if @post.closure_text %>
69
+ <div class="closure">
70
+ <p class="closure_text"><%= @post.closure_text %></p>
71
+ </div>
72
+ <% end %>
73
+ </section>
74
+ <section class="last_posts">
75
+ <% @related_posts.each do |related_post| %>
76
+ <aside class="small_post_banner">
77
+ <a href='<%= "/blog/#{related_post.slug}" %>' >
78
+ <img src="<%= related_post.banner_image %>" alt='<%= "#{@account.account_name} | #{related_post.main_title}" %>'>
79
+ <p class="published">
80
+ Atualizado em <%= related_post.updated_at.to_time.strftime '%e/%m/%Y' %>
81
+ </p>
82
+ <div class="small_post_content">
83
+ <h3>
84
+ <%= related_post.main_title %>
85
+ </h3>
86
+ </div>
87
+ </a>
88
+ </aside>
89
+ <% end %>
90
+ </section>
91
+ </div>
92
+ </article>
93
+ </main>
@@ -0,0 +1,2 @@
1
+ require 'iris-rails'
2
+ IrisRails::api_token = ENV['IRIS_TOKEN']
@@ -0,0 +1,3 @@
1
+ module Iris
2
+ VERSION = "0.1.0"
3
+ end
data/lib/iris-rails.rb ADDED
@@ -0,0 +1,123 @@
1
+ require 'rails'
2
+ require 'active_support/core_ext/numeric/time'
3
+ require 'active_support/dependencies'
4
+ require 'json'
5
+ require 'rest-client'
6
+
7
+ module IrisRails
8
+ class << self
9
+ attr_accessor :api_token
10
+ end
11
+
12
+ @api_url = 'https://iriscms.herokuapp.com/api/v1/'
13
+
14
+ def self.indexUrl
15
+ @api_url + 'posts?api_key=' + self.api_token
16
+ end
17
+
18
+ def self.postUrl(slug)
19
+ @api_url + "posts/#{slug}?api_key=" + self.api_token
20
+ end
21
+
22
+ def self.infoUrl
23
+ @api_url + 'account-info?api_key=' + self.api_token
24
+ end
25
+
26
+ class Error < StandardError; end
27
+ # Your code goes here...
28
+ def self.perform
29
+ "performing"
30
+ end
31
+
32
+ class Account
33
+ attr_accessor :account_name
34
+ attr_accessor :template
35
+ attr_accessor :type
36
+ attr_accessor :account_title
37
+ attr_accessor :account_description
38
+ attr_accessor :account_keyword
39
+
40
+ def initialize(attr = {})
41
+ @account_name = attr[:account_name]
42
+ @template = attr[:template]
43
+ @type = attr[:type]
44
+ @account_title = attr[:account_title]
45
+ @account_description = attr[:account_description]
46
+ @account_keyword = attr[:account_keyword]
47
+ end
48
+ end
49
+
50
+ class Post
51
+ @headers = {'Content-Type':'application/x-www-form-urlencoded'}
52
+ attr_accessor :main_title, :slug, :created_at, :updated_at, :banner_image,
53
+ :banner_text, :secondary_title, :first_introduction, :internal_links,
54
+ :second_introduction, :call_to_action_content, :call_to_action_link,
55
+ :call_to_action_link_description, :closure_text, :published, :keyphrase,
56
+ :meta_description, :seo_title, :publish_date, :published_at, :score,
57
+ :author_id, :author, :ordered_topics
58
+
59
+ def initialize(attr = {})
60
+ @main_title = attr["main_title"]
61
+ @slug = attr["slug"]
62
+ @created_at = attr["created_at"]
63
+ @updated_at = attr["updated_at"]
64
+ @banner_image = attr["banner_image"]
65
+ @banner_text = attr["banner_text"]
66
+ @secondary_title = attr["secondary_title"]
67
+ @first_introduction = attr["first_introduction"]
68
+ @internal_links = attr["internal_links"]
69
+ @second_introduction = attr["second_introduction"]
70
+ @call_to_action_content = attr["call_to_action_content"]
71
+ @call_to_action_link = attr["call_to_action_link"]
72
+ @call_to_action_link_description = attr["call_to_action_link_description"]
73
+ @closure_text = attr["closure_text"]
74
+ @published = attr["published"]
75
+ @keyphrase = attr["keyphrase"]
76
+ @meta_description = attr["meta_description"]
77
+ @seo_title = attr["seo_title"]
78
+ @publish_date = attr["publish_date"]
79
+ @published_at = attr["published_at"]
80
+ @score = attr["score"]
81
+ @author_id = attr["author_id"]
82
+ @author = attr["author"]
83
+ @ordered_topics = attr["ordered_topics"]
84
+ end
85
+
86
+ def self.find(slug)
87
+ url = IrisRails.postUrl(slug)
88
+ response = RestClient.get(url, @headers)
89
+ response = JSON.parse(response.body)
90
+ puts 'data'
91
+ post = self.new(response['data'])
92
+ related_posts = []
93
+ response['related_posts'].each do |related_post|
94
+ related_posts << self.new(related_post)
95
+ end
96
+ post.author = response['data']['author']
97
+ account = IrisRails::Account.new(
98
+ {account_name: response['account_name'],
99
+ template: response['template']}
100
+ )
101
+ return post, related_posts, account
102
+ end
103
+
104
+ def self.all
105
+ url = IrisRails.indexUrl
106
+ response = RestClient.get(url, @headers)
107
+ response = JSON.parse(response.body)
108
+ puts response
109
+ posts = []
110
+ response['data'].each do |post|
111
+ posts << self.new(post)
112
+ end
113
+ account = IrisRails::Account.new(
114
+ {account_name: response['account_name'],
115
+ template: response['template'],
116
+ account_title: response['account_title'],
117
+ account_description: response['account_description'],
118
+ account_keyword: response['account_keyword']}
119
+ )
120
+ return posts, account
121
+ end
122
+ end
123
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iris_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rayan Castro
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-03-31 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: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.2'
55
+ description: Easily render your iris blog server-side
56
+ email:
57
+ - rayancdc@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - CODE_OF_CONDUCT.md
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - bin/console
72
+ - bin/setup
73
+ - iris.gemspec
74
+ - lib/generators/iris/install_generator.rb
75
+ - lib/generators/templates/app/controllers/iris_rails/base_controller.rb
76
+ - lib/generators/templates/app/controllers/iris_rails/posts_controller.rb
77
+ - lib/generators/templates/app/helpers/meta_tags_helper.rb
78
+ - lib/generators/templates/app/views/iris_rails/posts/index.html.erb
79
+ - lib/generators/templates/app/views/iris_rails/posts/show.html.erb
80
+ - lib/generators/templates/config/initializers/iris_rails.rb
81
+ - lib/iris-rails.rb
82
+ - lib/iris/version.rb
83
+ homepage: https://github.com/horta-tech/iris-rails
84
+ licenses:
85
+ - MIT
86
+ metadata:
87
+ allowed_push_host: https://rubygems.org/
88
+ homepage_uri: https://github.com/horta-tech/iris-rails
89
+ source_code_uri: https://github.com/horta-tech/iris-rails
90
+ changelog_uri: https://github.com/horta-tech/iris-rails
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubygems_version: 3.0.3
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Easily render your iris blog server-side
110
+ test_files: []