Skip to content

Commit

Permalink
Application checks the site for upgrades.
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed Jan 30, 2011
1 parent b47d87a commit fa81dce
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
1 change: 1 addition & 0 deletions app/ui/mainwindow.rb
@@ -1,5 +1,6 @@
require 'app/boot'

require 'json'

# methods for the main app
module HH::App
Expand Down
36 changes: 18 additions & 18 deletions app/ui/tabs/home.rb
@@ -1,26 +1,26 @@
# the home tab content
# partly unfinished: some features have just started being implemented

class HH::SideTabs::Home < HH::SideTab
# unfinished method that asks if the user wants to upgrade
# def home_bulletin
# stack do
# background "#FF9".."#FFF"
# subtitle "Upgrade to 0.7?", :font => "Phonetica", :align => "center", :margin => 8
# para "A New Hackety Hack is Here!", :align => "center", :margin_bottom => 50
# glossb "Upgrade", :top => 90, :left => 0.42, :width => 100, :color => "red" do
# alert("No upgrades yet.")
# end
# end
# stack do
# background black(0.4)..black(0.0)
# image 1, 10
# end
# end
def home_bulletin(new_version)
@bulletin_stack.clear do
stack do
background "#FF9"
subtitle "Upgrade to #{new_version}!", :font => "Phonetica", :align => "center", :margin => 8
para "A New Hackety Hack is Here!", :align => "center"
para "Go to ", link("hackety-hack.com", :click => "http://hackety-hack.com/download"), " to get it!", :align => "center", :margin_bottom => 20
end
end
end
def initialize *args, &blk
super *args, &blk
# never changes so is most efficient to load here
@samples = HH.samples
Upgrade::check_latest_version do |version|
warn "version #{version['current_version']}"
if version['current_version'] != HH::VERSION
home_bulletin(version['current_version'])
end
end
end

# auxiliary method to displays the arrows, for example in case
Expand Down Expand Up @@ -109,8 +109,6 @@ def home_lessons
para "You have no lessons.", :margin_left => 12, :font => "Lacuna Regular"
end

# add a tab at the top of the homepane, for now there is only one tab:
# (Programs)
def hometab name, bg, starts = false, &blk
tab =
stack :margin_top => (starts ? 6 : 10), :margin_left => 14, :width => 120 do
Expand Down Expand Up @@ -170,6 +168,8 @@ def content
background rgb(233, 239, 224, 0.85)..rgb(233, 239, 224, 0.0)
image 10, 70
end
@bulletin_stack = stack do
end
end
end
end
1 change: 1 addition & 0 deletions lib/dev/init.rb
Expand Up @@ -12,6 +12,7 @@
HH::FONTS = HH::HOME + "/fonts"
HH::LESSONS = HH::HOME + "/lessons"
$LOAD_PATH << HH::HOME
HH::VERSION = 1.0

# platform-specific directories
case RUBY_PLATFORM when /win32/, /i386-mingw32/
Expand Down
1 change: 1 addition & 0 deletions lib/web/all.rb
@@ -1,2 +1,3 @@
require 'lib/web/hacker'
require 'lib/web/web'
require 'lib/web/version'
14 changes: 14 additions & 0 deletions lib/web/version.rb
@@ -0,0 +1,14 @@
require 'lib/web/yaml'

module Upgrade
class << self
include HH::YAML

def check_latest_version &blk
http('GET', "/version.json") do |result|
response = JSON.parse(result.response.body)
blk[response]
end
end
end
end

0 comments on commit fa81dce

Please sign in to comment.