History

Route external redirections through a different origin

Thibaut committed 11 years ago

Commit ac2cbdd1 parent e1ec0f56 files · +20 −11Browse files

Unified · Split

6 files
  1. README.md +1 −1
  2. assets/javascripts/news.json +1 −1
  3. assets/javascripts/templates/notif_tmpl.coffee +4 −4
  4. assets/javascripts/templates/pages/about_tmpl.coffee +3 −3
  5. assets/javascripts/templates/pages/root_tmpl.coffee.erb +2 −2
  6. lib/app.rb +9 −0
README.md+1−1
@@ -3,7 +3,7 @@ · 2 unmodified lines
33 DevDocs combines multiple API documentations in a fast, organized, and searchable interface.
44
55 * Created by [Thibaut Courouble](http://thibaut.me)
6−* Supported by [JetBrains](http://devdocs.io/s/jetbrains) and [Code School](http://devdocs.io/s/code-school)
6+* Supported by [JetBrains](http://out.devdocs.io/s/jetbrains) and [Code School](http://out.devdocs.io/s/code-school)
77
88 Keep track of development and community news:
99
assets/javascripts/news.json+1−1
@@ -17,7 +17,7 @@ · 16 unmodified lines
1717 "Added <code class=\"_label\">shift + &darr;/&uarr;</code> shortcut for scrolling (same as <code class=\"_label\">alt + &darr;/&uarr;</code>)."
1818 ], [
1919 "2015-07-12",
20− "New sponsors: <a href=\"http://devdocs.io/s/jetbrains\">JetBrains</a> and <a href=\"http://devdocs.io/s/code-school\">Code School</a>\nIf you like DevDocs, please take a moment to check out their products — they're awesome!"
20+ "New sponsors: <a href=\"http://out.devdocs.io/s/jetbrains\">JetBrains</a> and <a href=\"http://out.devdocs.io/s/code-school\">Code School</a>\nIf you like DevDocs, please take a moment to check out their products — they're awesome!"
2121 ], [
2222 "2015-07-05",
2323 "New documentations: <a href=\"/drupal/\">Drupal</a>, <a href=\"/vue/\">Vue.js</a>, <a href=\"/phaser/\">Phaser</a> and <a href=\"/webpack/\">webpack</a>"
assets/javascripts/templates/notif_tmpl.coffee+4−4
@@ -29,15 +29,15 @@ app.templates.notifNews = (news) -> · 28 unmodified lines
2929 app.templates.notifShare = ->
3030 textNotif """ Hi there! """,
3131 """ Like DevDocs? Help us reach more developers by sharing the link with your friends, on
32− <a href="/s/tw" target="_blank">Twitter</a>, <a href="/s/fb" target="_blank">Facebook</a>,
33− <a href="/s/re" target="_blank">Reddit</a>, etc.<br>Thanks :) """
32+ <a href="http://out.devdocs.io/s/tw" target="_blank">Twitter</a>, <a href="http://out.devdocs.io/s/fb" target="_blank">Facebook</a>,
33+ <a href="http://out.devdocs.io/s/re" target="_blank">Reddit</a>, etc.<br>Thanks :) """
3434
3535 app.templates.notifThanks = ->
3636 textNotif """ Hi there! """,
3737 """ <p class="_notif-text">Like DevDocs? Check out these awesome companies who are making it possible:
3838 <ul class="_notif-list">
39− <li><a href="http://devdocs.io/s/jetbrains" target="_blank">JetBrains</a> — We make software development a more productive and enjoyable experience through smart IDEs and code editors.
40− <li><a href="http://devdocs.io/s/code-school" target="_blank">Code School</a> — Learn new skills from the comfort of your own browser. Offering more than 45 courses covering JavaScript, HTML/CSS, Ruby, Git, and iOS for only $29/month.
39+ <li><a href="http://out.devdocs.io/s/jetbrains" target="_blank">JetBrains</a> — We make software development a more productive and enjoyable experience through smart IDEs and code editors.
40+ <li><a href="http://out.devdocs.io/s/code-school" target="_blank">Code School</a> — Learn new skills from the comfort of your own browser. Offering more than 45 courses covering JavaScript, HTML/CSS, Ruby, Git, and iOS for only $29/month.
4141 </ul>
4242 <p class="_notif-text">Have a great day :) """
4343
assets/javascripts/templates/pages/about_tmpl.coffee+3−3
@@ -13,7 +13,7 @@ app.templates.aboutPage = -> """ · 12 unmodified lines
1313 <p>DevDocs combines multiple API documentations in a fast, organized, and searchable interface.
1414 <ul>
1515 <li>Created and maintained by <a href="http://thibaut.me">Thibaut Courouble</a>
16− <li>Supported by <a href="http://devdocs.io/s/jetbrains">JetBrains</a> and <a href="http://devdocs.io/s/code-school">Code School</a>
16+ <li>Supported by <a href="http://out.devdocs.io/s/jetbrains">JetBrains</a> and <a href="http://out.devdocs.io/s/code-school">Code School</a>
1717 <li>Free and <a href="https://github.com/Thibaut/devdocs">open source</a>
1818 <iframe class="_github-btn" src="https://ghbtns.com/github-btn.html?user=Thibaut&repo=devdocs&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100" height="20"></iframe>
1919 </ul>
@@ -30,8 +30,8 @@ app.templates.aboutPage = -> """ · 10 unmodified lines
3030
3131 <p><strong>Special thanks to:</strong>
3232 <ul>
33− <li><a href="http://devdocs.io/s/maxcdn">MaxCDN</a> and <a href="http://get.gaug.es/?utm_source=devdocs&utm_medium=referral&utm_campaign=sponsorships" title="Real Time Web Analytics">Gauges</a> for offering a free account to DevDocs
34− <li><a href="http://devdocs.io/s/shopify">Shopify</a> for supporting DevDocs in the past
33+ <li><a href="http://out.devdocs.io/s/maxcdn">MaxCDN</a> and <a href="http://get.gaug.es/?utm_source=devdocs&utm_medium=referral&utm_campaign=sponsorships" title="Real Time Web Analytics">Gauges</a> for offering a free account to DevDocs
34+ <li><a href="http://out.devdocs.io/s/shopify">Shopify</a> for supporting DevDocs in the past
3535 <li><a href="https://www.heroku.com">Heroku</a> and <a href="http://newrelic.com">New Relic</a> for providing awesome free service
3636 <li>Daniel Bruce for the <a href="http://www.entypo.com">Entypo</a> pictograms
3737 <li><a href="http://www.jeremykratz.com/">Jeremy Kratz</a> for the C/C++ logo
assets/javascripts/templates/pages/root_tmpl.coffee.erb+2−2
@@ -3,7 +3,7 @@ jetBrainsLink = (className) -> · 2 unmodified lines
33 path = "/#{type}" if type
44
55 """
6− <a href="http://devdocs.io/s/jetbrains#{path || ''}" class="#{className}">
6+ <a href="http://out.devdocs.io/s/jetbrains#{path || ''}" class="#{className}">
77 <span class="_logo-thx _jetbrains-logo">JetBrains</span>
88 <span class="_logo-info">#{JETBRAINS_INFO[type || 'default']}</span>
99 </a>
@@ -29,7 +29,7 @@ jetBrainsType = -> · 19 unmodified lines
2929 'web'
3030
3131 codeSchoolLink = (className) -> """
32− <a href="http://devdocs.io/s/code-school" class="#{className}">
32+ <a href="http://out.devdocs.io/s/code-school" class="#{className}">
3333 <span class="_logo-thx _code-school-logo">Code School</span>
3434 <span class="_logo-info">With more than 45 courses covering JavaScript, HTML/CSS, Ruby, Git, and iOS, Code School pairs experienced instructors with engaging content. Start learning at codeschool.com.</span>
3535 </a>
lib/app.rb+9−0
@@ -172,6 +172,15 @@ class App < Sinatra::Application · 171 unmodified lines
172172 halt erb :unsupported if unsupported_browser?
173173 end
174174
175+ OUT_HOST = 'out.devdocs.io'.freeze
176+
177+ before do
178+ if request.host == OUT_HOST && !request.path.start_with?('/s/')
179+ query_string = "?#{request.query_string}" unless request.query_string.empty?
180+ redirect "http://devdocs.io#{request.path}#{query_string}", 302
181+ end
182+ end
183+
175184 get '/manifest.appcache' do
176185 content_type 'text/cache-manifest'
177186 expires 0, :'no-cache'