Skip to content
Browse files

[+] Can now get Cocoa framework version number in JSON format

(See Check for framework update when in Simulator - gcerquant/UpdateKit#5)
[+] Display icon from AppStore in index / edit / show page of iOS app
  • Loading branch information...
1 parent 568a40b commit 0ca8399ce928e0eaca99f1ebb8ace28244c6e4ae @gcerquant committed Feb 10, 2012
View
5 app/controllers/application_controller.rb
@@ -5,5 +5,10 @@ class ApplicationController < ActionController::Base
rescue_from CanCan::AccessDenied do |exception|
redirect_to root_url, :alert => "Access denied."
end
+
+
+ def cocoa_framework_version
+ render :json => { :current_version => "0.1" }
+ end
end
View
28 app/models/ios_application.rb
@@ -74,7 +74,35 @@ def self.update_all_applications_version_number
end
+ def fetch_application_information_from_apple_api
+ puts "HIIIIIIII"
+
+ begin
+ json = open "http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa/wsLookup?bundleId=#{application_bundle_identifier}"
+ rescue
+ # a multitude of HTTP-related errors can occur
+ end
+
+ json_string = json.read
+
+ application_information = ActiveSupport::JSON.decode(json_string)
+
+ if (application_information['resultCount'] == 1)
+ self.icon_small_url = application_information['results'][0]['artworkUrl60']
+ self.icon_url = application_information['results'][0]['artworkUrl512']
+
+ self.save
+
+ else
+ puts "Unexpected number of result in API search"
+ end
+
+ end
+
+
def fetch_version_number_from_apple_server
+ fetch_application_information_from_apple_api()
+
if apple_identifier.nil?
return :alert => "Unable to fetch version number because AppleID is not specified"
end
View
3 app/views/ios_applications/_form.html.erb
@@ -11,6 +11,9 @@
</div>
<% end %>
+
+ <%= image_tag(@ios_application.icon_url, :size => "256x256") if @ios_application.icon_url %>
+
<div class="field">
<b><%= f.label :title %><br /></b>
<%= f.text_field :title, :placeholder => "SuperAwesomeApplication" %> (optional)
View
6 app/views/ios_applications/edit.html.erb
@@ -1,9 +1,3 @@
-
-
-
-
-<hr>
-
<h1>Editing <%= @ios_application.title %> </h1>
<%= render 'form' %>
View
2 app/views/ios_applications/index.html.erb
@@ -12,6 +12,7 @@ end
<table>
<tr>
+ <th></th>
<th>Title</th>
<th>Application bundle identifier</th>
<th>Published version number</th>
@@ -32,6 +33,7 @@ end
end
end
%>" >
+ <td><%= image_tag(ios_application.icon_small_url, :size => "35x35") if ios_application.icon_small_url %></td>
<td><%= ios_application.title %></td>
<td><%= ios_application.application_bundle_identifier %></td>
<td><%= ios_application.published_version_number %></td>
View
3 app/views/ios_applications/show.html.erb
@@ -1,4 +1,7 @@
+
+<%= image_tag(@ios_application.icon_url, :size => "256x256") if @ios_application.icon_url %>
+
<p>
<b>Title:</b>
<%= @ios_application.title %>
View
2 config/environments/development.rb
@@ -34,4 +34,6 @@
# Expands the lines which load the assets
config.assets.debug = true
+
+
end
View
4 config/routes.rb
@@ -12,6 +12,10 @@
match 'ios_applications/:id/fetch_version_number' => "ios_applications#fetch_version_number", :as => "ios_application_fetch_version_number"
match 'ios_applications/:id/protect' => "ios_applications#protect_application", :as => "ios_application_protect_application"
match 'ios_applications/:id/unprotect' => "ios_applications#unprotect_application", :as => "ios_application_unprotect_application"
+
+
+
+ match 'cocoa_framework_version' => "application#cocoa_framework_version"
# The priority is based upon order of creation:
# first created -> highest priority.
View
4 db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120109184231) do
+ActiveRecord::Schema.define(:version => 20120210151822) do
create_table "ios_applications", :force => true do |t|
t.string "title"
@@ -23,6 +23,8 @@
t.datetime "updated_at"
t.boolean "manual_version_management"
t.integer "user_id"
+ t.string "icon_small_url"
+ t.string "icon_url"
end
create_table "users", :force => true do |t|

0 comments on commit 0ca8399

Please sign in to comment.
Something went wrong with that request. Please try again.