[Xfce4-commits] <archive:master> Add geolocation functionality.
Nick Schermer
noreply at xfce.org
Sat Nov 12 14:42:01 CET 2011
Updating branch refs/heads/master
to abae7304ae51fee6feec76331e8089df2b72bcbf (commit)
from 60177d4e63713e201eeef773e78d8a19cd616c35 (commit)
commit abae7304ae51fee6feec76331e8089df2b72bcbf
Author: Nick Schermer <nick at xfce.org>
Date: Sat Nov 12 14:40:05 2011 +0100
Add geolocation functionality.
fancyindex/main.rb | 6 ++++++
fancyindex/views/geolocation.haml | 17 +++++++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/fancyindex/main.rb b/fancyindex/main.rb
index 6f7af66..8e5a7b7 100644
--- a/fancyindex/main.rb
+++ b/fancyindex/main.rb
@@ -8,6 +8,12 @@ module Fancyindex
class Application < Sinatra::Base
include Fancyindex::Models
+ # used in the xfce weather plugin
+ get '/geolocation' do
+ content_type 'application/xml', :charset => 'utf-8'
+ haml :geolocation
+ end
+
get '/*' do |requesturi|
root_dir = '/var/www/archive.xfce.org/'
path = File.join(root_dir, requesturi)
diff --git a/fancyindex/views/geolocation.haml b/fancyindex/views/geolocation.haml
new file mode 100644
index 0000000..7100ffe
--- /dev/null
+++ b/fancyindex/views/geolocation.haml
@@ -0,0 +1,17 @@
+%Response
+ - if env[:GEOIP_ADDR]
+ %Ip #{env[:GEOIP_ADDR]}
+ - if env[:GEOIP_COUNTRY_CODE]
+ %CountryCode #{env[:GEOIP_COUNTRY_CODE]}
+ - if env[:GEOIP_COUNTRY_NAME]
+ %CountryName #{env[:GEOIP_COUNTRY_NAME]}
+ - if env[:GEOIP_REGION]
+ %RegionCode #{env[:GEOIP_REGION]}
+ - if env[:GEOIP_REGION_NAME]
+ %RegionName #{env[:GEOIP_REGION_NAME]}
+ - if env[:GEOIP_CITY]
+ %City #{env[:GEOIP_CITY]}
+ - if env[:GEOIP_LATITUDE]
+ %Latitude #{env[:GEOIP_LATITUDE]}
+ - if env[:GEOIP_LONGITUDE]
+ %Longitude #{env[:GEOIP_LONGITUDE]}
More information about the Xfce4-commits
mailing list