slideshow 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.8.4 / 2010-06-24
2
+
3
+ * Added support for proxy via HTTP_PROXY env for fetching templates from the internet
4
+
1
5
  === 0.8.3 / 2010-06-23
2
6
 
3
7
  * Added support for @slides and @content variables in templates
data/lib/slideshow/gen.rb CHANGED
@@ -252,9 +252,30 @@ class Gen
252
252
 
253
253
  uri = URI.parse( src )
254
254
 
255
- # todo: add our own agent HTTP header for identification?
256
- response = Net::HTTP.get_response( uri )
257
-
255
+ # new code: honor proxy env variable HTTP_PROXY
256
+ proxy = ENV['HTTP_PROXY']
257
+ proxy = ENV['http_proxy'] if proxy.nil? # try possible lower/case env variable (for *nix systems) is this necessary??
258
+
259
+ if proxy
260
+ proxy = URI.parse( proxy )
261
+ logger.debug "using net http proxy: proxy.host=#{proxy.host}, proxy.port=#{proxy.port}"
262
+ if proxy.user && proxy.password
263
+ logger.debug " using credentials: proxy.user=#{proxy.user}, proxy.password=****"
264
+ else
265
+ logger.debug " using no credentials"
266
+ end
267
+ else
268
+ logger.debug "using direct net http access; no proxy configured"
269
+ proxy = OpenStruct.new # all fields return nil (e.g. proxy.host, etc.)
270
+ end
271
+
272
+ # same as old code w/o proxy: response = Net::HTTP.get_response( uri )
273
+
274
+ response = Net::HTTP::Proxy(proxy.host,proxy.port,proxy.user,proxy.password).start( uri.host, uri.port ) do |http|
275
+ return http.request_get(uri.request_uri)
276
+ end
277
+
278
+
258
279
  unless response.code == '200' # note: responsoe.code is a string
259
280
  msg = "#{response.code} #{response.message}"
260
281
  puts "*** error: #{msg}"
data/lib/slideshow.rb CHANGED
@@ -11,6 +11,7 @@ require 'fileutils'
11
11
  require 'pp'
12
12
  require 'uri'
13
13
  require 'net/http'
14
+ require 'ostruct'
14
15
 
15
16
  # required gems
16
17
  require 'redcloth' # default textile library
@@ -23,7 +24,7 @@ require 'slideshow/gen'
23
24
 
24
25
  module Slideshow
25
26
 
26
- VERSION = '0.8.3'
27
+ VERSION = '0.8.4'
27
28
 
28
29
  def Slideshow.main
29
30
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slideshow
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 55
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 3
10
- version: 0.8.3
9
+ - 4
10
+ version: 0.8.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gerald Bauer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-23 00:00:00 +02:00
18
+ date: 2010-06-24 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency