rails_sitemap 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 217f47a29696fa453e14855e0222395e7dad5591
4
- data.tar.gz: 893514e7a59604bc79d1456b7106a0f1c3856e63
3
+ metadata.gz: 9ebccee49882668c55488c5cd0c51966e6b968c1
4
+ data.tar.gz: 7c2055fd0d4f5ae0e46f58f42ec40363905e9804
5
5
  SHA512:
6
- metadata.gz: ad9de992eb800cf93d9459552e29ebcc0ed932854927a0dc1e7e8afca642927d72968522a6cfc36ede5a12e16b0b5b2a6932206362ebe8a1fd004b47356d0577
7
- data.tar.gz: e15a7f635ea98e3b0b9ef551a3b2c26e2d98e66d2b62dd5cad5df038899449b250952d21816b44fb6a8b0e0136e886851a96a6c9ca98f7176fe47bcc654a2fb0
6
+ metadata.gz: 5fe401256d3676970734155a3efd0a661d08c3bf54533b3edefd1bcb540da43797f318837323e6f99ff82f9273c93a0a70a201640f9ca8d7309f1da3b3cee9bb
7
+ data.tar.gz: aaa73549f582e60d041d22ff29c72371fe4bf8672b27f73679b074580c6147f06984387ae8cb6eb8557b7cf5469af1a333e5b4412be2a81224b21e78af9dcd2b
data/README.rdoc CHANGED
@@ -1,3 +1,15 @@
1
1
  = RailsSitemap
2
2
 
3
- This project rocks and uses MIT-LICENSE.
3
+ ## Instalation
4
+
5
+ Add the gem in your Gemfile
6
+
7
+ ```ruby
8
+ gem 'rails_sitemap'
9
+ ```
10
+
11
+ Mount the engine on your rails application
12
+
13
+ ```ruby
14
+ mount RailsSitemap::Engine => "/"
15
+ ```
@@ -3,6 +3,7 @@ module RailsSitemap
3
3
  BANNED_CONTROLLERS = ['rails/info', nil, 'errors', 'rails/mailers']
4
4
  BANNED_ACTIONS = %w(show destroy update edit new create)
5
5
  before_action :set_routes, only: :index
6
+ before_action :set_current_domain, only: :index
6
7
 
7
8
  def index
8
9
  respond_to do |format|
@@ -32,5 +33,12 @@ module RailsSitemap
32
33
  route[:path][0..-11]
33
34
  end
34
35
  end
36
+
37
+ def set_current_domain
38
+ uri = URI.parse(request.original_url)
39
+ pre_html = uri.html_safe? ? 'https://' : 'http://'
40
+
41
+ @current_domain = pre_html + uri.hostname
42
+ end
35
43
  end
36
44
  end
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:geo="http://www.google.com/geo/schemas/sitemap/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:pagemap="http://www.google.com/schemas/sitemap-pagemap/1.0" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
3
3
  <url>
4
- <loc>localhost:3000</loc>
4
+ <loc><%= @current_domain %></loc>
5
5
  <lastmod>2016-09-22T18:11:05-03:00</lastmod>
6
6
  <changefreq>always</changefreq>
7
7
  <priority>1.0</priority>
@@ -9,7 +9,7 @@
9
9
 
10
10
  <% @routes.each do |route| %>
11
11
  <url>
12
- <loc><%= "localhost:3000#{route}" %></loc>
12
+ <loc><%= @current_domain + route %></loc>
13
13
  <lastmod>2016-09-22T18:11:05-03:00</lastmod>
14
14
  <changefreq>weekly</changefreq>
15
15
  <priority>0.5</priority>
@@ -1,3 +1,3 @@
1
1
  module RailsSitemap
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
@@ -741,3 +741,123 @@ Processing by RailsSitemap::SitemapController#index as XML
741
741
  Rendered /Users/pgonzaga/repositories/rails_sitemap/app/views/rails_sitemap/sitemap/index.xml.erb (0.0ms)
742
742
  Completed 200 OK in 1ms (Views: 0.4ms | ActiveRecord: 0.0ms)
743
743
   (0.0ms) rollback transaction
744
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
745
+  (2.8ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
746
+  (0.1ms) select sqlite_version(*)
747
+  (3.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
748
+  (0.1ms) SELECT version FROM "schema_migrations"
749
+  (3.6ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
750
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
751
+  (0.1ms) begin transaction
752
+ ----------------------------
753
+ RailsSitemapTest: test_truth
754
+ ----------------------------
755
+  (0.0ms) rollback transaction
756
+  (0.1ms) begin transaction
757
+ --------------------------------------------------------
758
+ SitemapControllerTest: test_should_return_a_success_code
759
+ --------------------------------------------------------
760
+ Started GET "/sitemap.xml" for 127.0.0.1 at 2016-09-23 15:07:35 -0300
761
+ Processing by RailsSitemap::SitemapController#index as XML
762
+ Rendered /Users/pgonzaga/repositories/rails_sitemap/app/views/rails_sitemap/sitemap/index.xml.erb (35.8ms)
763
+ Completed 500 Internal Server Error in 562078ms (ActiveRecord: 0.0ms)
764
+  (0.1ms) rollback transaction
765
+  (0.1ms) begin transaction
766
+ -------------------------------------------------------
767
+ SitemapControllerTest: test_should_return_the_right_xml
768
+ -------------------------------------------------------
769
+ Started GET "/sitemap.xml" for 127.0.0.1 at 2016-09-23 15:16:57 -0300
770
+ Processing by RailsSitemap::SitemapController#index as XML
771
+ Rendered /Users/pgonzaga/repositories/rails_sitemap/app/views/rails_sitemap/sitemap/index.xml.erb (37.4ms)
772
+ Completed 500 Internal Server Error in 1158ms (ActiveRecord: 0.0ms)
773
+  (0.1ms) rollback transaction
774
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
775
+  (2.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
776
+  (0.1ms) select sqlite_version(*)
777
+  (3.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
778
+  (0.2ms) SELECT version FROM "schema_migrations"
779
+  (3.4ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
780
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
781
+  (0.1ms) begin transaction
782
+ ----------------------------
783
+ RailsSitemapTest: test_truth
784
+ ----------------------------
785
+  (0.0ms) rollback transaction
786
+  (0.0ms) begin transaction
787
+ --------------------------------------------------------
788
+ SitemapControllerTest: test_should_return_a_success_code
789
+ --------------------------------------------------------
790
+ Started GET "/sitemap.xml" for 127.0.0.1 at 2016-09-23 15:17:28 -0300
791
+ Processing by RailsSitemap::SitemapController#index as XML
792
+ Rendered /Users/pgonzaga/repositories/rails_sitemap/app/views/rails_sitemap/sitemap/index.xml.erb (35.4ms)
793
+ Completed 500 Internal Server Error in 46ms (ActiveRecord: 0.0ms)
794
+  (0.1ms) rollback transaction
795
+  (0.1ms) begin transaction
796
+ -------------------------------------------------------
797
+ SitemapControllerTest: test_should_return_the_right_xml
798
+ -------------------------------------------------------
799
+ Started GET "/sitemap.xml" for 127.0.0.1 at 2016-09-23 15:17:29 -0300
800
+ Processing by RailsSitemap::SitemapController#index as XML
801
+ Rendered /Users/pgonzaga/repositories/rails_sitemap/app/views/rails_sitemap/sitemap/index.xml.erb (27.6ms)
802
+ Completed 500 Internal Server Error in 28ms (ActiveRecord: 0.0ms)
803
+  (0.0ms) rollback transaction
804
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
805
+  (2.7ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
806
+  (0.1ms) select sqlite_version(*)
807
+  (3.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
808
+  (0.1ms) SELECT version FROM "schema_migrations"
809
+  (3.4ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
810
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
811
+  (0.1ms) begin transaction
812
+ --------------------------------------------------------
813
+ SitemapControllerTest: test_should_return_a_success_code
814
+ --------------------------------------------------------
815
+ Started GET "/sitemap.xml" for 127.0.0.1 at 2016-09-23 15:17:58 -0300
816
+ Processing by RailsSitemap::SitemapController#index as XML
817
+ Rendered /Users/pgonzaga/repositories/rails_sitemap/app/views/rails_sitemap/sitemap/index.xml.erb (1.0ms)
818
+ Completed 200 OK in 10ms (Views: 9.4ms | ActiveRecord: 0.0ms)
819
+  (0.1ms) rollback transaction
820
+  (0.1ms) begin transaction
821
+ -------------------------------------------------------
822
+ SitemapControllerTest: test_should_return_the_right_xml
823
+ -------------------------------------------------------
824
+ Started GET "/sitemap.xml" for 127.0.0.1 at 2016-09-23 15:17:58 -0300
825
+ Processing by RailsSitemap::SitemapController#index as XML
826
+ Rendered /Users/pgonzaga/repositories/rails_sitemap/app/views/rails_sitemap/sitemap/index.xml.erb (0.1ms)
827
+ Completed 200 OK in 1ms (Views: 0.3ms | ActiveRecord: 0.0ms)
828
+  (0.1ms) rollback transaction
829
+  (0.0ms) begin transaction
830
+ ----------------------------
831
+ RailsSitemapTest: test_truth
832
+ ----------------------------
833
+  (0.0ms) rollback transaction
834
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
835
+  (2.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
836
+  (0.1ms) select sqlite_version(*)
837
+  (3.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
838
+  (0.2ms) SELECT version FROM "schema_migrations"
839
+  (3.5ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
840
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
841
+  (0.1ms) begin transaction
842
+ --------------------------------------------------------
843
+ SitemapControllerTest: test_should_return_a_success_code
844
+ --------------------------------------------------------
845
+ Started GET "/sitemap.xml" for 127.0.0.1 at 2016-09-23 15:19:36 -0300
846
+ Processing by RailsSitemap::SitemapController#index as XML
847
+ Rendered /Users/pgonzaga/repositories/rails_sitemap/app/views/rails_sitemap/sitemap/index.xml.erb (1.0ms)
848
+ Completed 200 OK in 12ms (Views: 11.6ms | ActiveRecord: 0.0ms)
849
+  (0.1ms) rollback transaction
850
+  (0.1ms) begin transaction
851
+ -------------------------------------------------------
852
+ SitemapControllerTest: test_should_return_the_right_xml
853
+ -------------------------------------------------------
854
+ Started GET "/sitemap.xml" for 127.0.0.1 at 2016-09-23 15:19:36 -0300
855
+ Processing by RailsSitemap::SitemapController#index as XML
856
+ Rendered /Users/pgonzaga/repositories/rails_sitemap/app/views/rails_sitemap/sitemap/index.xml.erb (0.1ms)
857
+ Completed 200 OK in 1ms (Views: 0.3ms | ActiveRecord: 0.0ms)
858
+  (0.0ms) rollback transaction
859
+  (0.0ms) begin transaction
860
+ ----------------------------
861
+ RailsSitemapTest: test_truth
862
+ ----------------------------
863
+  (0.0ms) rollback transaction
@@ -8,6 +8,6 @@ class SitemapControllerTest < ActionDispatch::IntegrationTest
8
8
 
9
9
  test 'should return the right xml' do
10
10
  get '/sitemap.xml'
11
- assert_equal response.body, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:geo=\"http://www.google.com/geo/schemas/sitemap/1.0\" xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\" xmlns:mobile=\"http://www.google.com/schemas/sitemap-mobile/1.0\" xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\" xmlns:pagemap=\"http://www.google.com/schemas/sitemap-pagemap/1.0\" xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">\n <url>\n <loc>localhost:3000</loc>\n <lastmod>2016-09-22T18:11:05-03:00</lastmod>\n <changefreq>always</changefreq>\n <priority>1.0</priority>\n </url>\n\n <url>\n <loc>localhost:3000/articles</loc>\n <lastmod>2016-09-22T18:11:05-03:00</lastmod>\n <changefreq>weekly</changefreq>\n <priority>0.5</priority>\n </url>\n</urlset>\n"
11
+ assert_equal response.body, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:geo=\"http://www.google.com/geo/schemas/sitemap/1.0\" xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\" xmlns:mobile=\"http://www.google.com/schemas/sitemap-mobile/1.0\" xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\" xmlns:pagemap=\"http://www.google.com/schemas/sitemap-pagemap/1.0\" xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">\n <url>\n <loc>http://www.example.com</loc>\n <lastmod>2016-09-22T18:11:05-03:00</lastmod>\n <changefreq>always</changefreq>\n <priority>1.0</priority>\n </url>\n\n <url>\n <loc>http://www.example.com/articles</loc>\n <lastmod>2016-09-22T18:11:05-03:00</lastmod>\n <changefreq>weekly</changefreq>\n <priority>0.5</priority>\n </url>\n</urlset>\n"
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_sitemap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Gonzaga
@@ -14,16 +14,16 @@ dependencies:
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.5.2
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 4.2.5.2
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement