eve-4 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.gitignore +0 -0
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/dictionaries/tylercollins.xml +3 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/eve-updated.iml +58 -0
- data/.idea/misc.xml +5 -0
- data/.idea/modules.xml +9 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/workspace.xml +554 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +108 -0
- data/History.txt +7 -0
- data/Rakefile +37 -0
- data/eve.gemspec +36 -0
- data/lib/eve.rb +26 -0
- data/lib/eve/api.rb +249 -0
- data/lib/eve/api/connectivity.rb +39 -0
- data/lib/eve/api/request.rb +80 -0
- data/lib/eve/api/response.rb +34 -0
- data/lib/eve/api/response/result.rb +87 -0
- data/lib/eve/api/response/row.rb +42 -0
- data/lib/eve/api/response/rowset.rb +18 -0
- data/lib/eve/api/services.rb +20 -0
- data/lib/eve/api/services/account.rb +12 -0
- data/lib/eve/api/services/character.rb +96 -0
- data/lib/eve/api/services/corporation.rb +150 -0
- data/lib/eve/api/services/eve.rb +76 -0
- data/lib/eve/api/services/map.rb +45 -0
- data/lib/eve/api/services/misc.rb +24 -0
- data/lib/eve/api/services/server.rb +20 -0
- data/lib/eve/dependencies.rb +48 -0
- data/lib/eve/deprecation.rb +3 -0
- data/lib/eve/errors.rb +129 -0
- data/lib/eve/errors/authentication_errors.rb +33 -0
- data/lib/eve/errors/internal_errors.rb +64 -0
- data/lib/eve/errors/miscellaneous_errors.rb +19 -0
- data/lib/eve/errors/user_input_errors.rb +62 -0
- data/lib/eve/javascript_helper.rb +196 -0
- data/lib/eve/trust.rb +87 -0
- data/lib/eve/trust/controller_helpers.rb +86 -0
- data/lib/eve/trust/igb_interface.rb +92 -0
- data/lib/eve/trust/mime_types.rb +4 -0
- data/lib/eve/version.rb +8 -0
- data/log/development.log +30 -0
- data/spec/controllers/controller_helpers_spec.rb +91 -0
- data/spec/helpers/javascript_helper_spec.rb +80 -0
- data/spec/helpers/view_helper_spec.rb +7 -0
- data/spec/lib/eve/api/calls/account/characters_spec.rb +22 -0
- data/spec/lib/eve/api/calls/character/account_balance_spec.rb +21 -0
- data/spec/lib/eve/api/calls/character/asset_list_spec.rb +23 -0
- data/spec/lib/eve/api/calls/character/character_sheet_spec.rb +51 -0
- data/spec/lib/eve/api/calls/character/fac_war_stats_spec.rb +31 -0
- data/spec/lib/eve/api/calls/character/industry_jobs_spec.rb +27 -0
- data/spec/lib/eve/api/calls/character/kill_log_spec.rb +27 -0
- data/spec/lib/eve/api/calls/character/mail_messages_spec.rb +21 -0
- data/spec/lib/eve/api/calls/character/mailing_lists_spec.rb +21 -0
- data/spec/lib/eve/api/calls/character/market_orders_spec.rb +21 -0
- data/spec/lib/eve/api/calls/character/medals_spec.rb +24 -0
- data/spec/lib/eve/api/calls/character/research_spec.rb +21 -0
- data/spec/lib/eve/api/calls/character/skill_in_training_spec.rb +44 -0
- data/spec/lib/eve/api/calls/character/skill_queue_spec.rb +21 -0
- data/spec/lib/eve/api/calls/character/standings_spec.rb +26 -0
- data/spec/lib/eve/api/calls/character/wallet_journal_spec.rb +21 -0
- data/spec/lib/eve/api/calls/character/wallet_transactions_spec.rb +21 -0
- data/spec/lib/eve/api/calls/character_portrait_spec.rb +17 -0
- data/spec/lib/eve/api/calls/corporation/account_balances_spec.rb +21 -0
- data/spec/lib/eve/api/calls/corporation/asset_list_spec.rb +25 -0
- data/spec/lib/eve/api/calls/corporation/container_log_spec.rb +23 -0
- data/spec/lib/eve/api/calls/corporation/corporation_sheet_spec.rb +36 -0
- data/spec/lib/eve/api/calls/corporation/fac_war_stats_spec.rb +23 -0
- data/spec/lib/eve/api/calls/corporation/industry_jobs_spec.rb +30 -0
- data/spec/lib/eve/api/calls/corporation/kill_log_spec.rb +27 -0
- data/spec/lib/eve/api/calls/corporation/market_orders_spec.rb +22 -0
- data/spec/lib/eve/api/calls/corporation/medals_spec.rb +21 -0
- data/spec/lib/eve/api/calls/corporation/member_medals_spec.rb +21 -0
- data/spec/lib/eve/api/calls/corporation/member_security_log_spec.rb +24 -0
- data/spec/lib/eve/api/calls/corporation/member_security_spec.rb +25 -0
- data/spec/lib/eve/api/calls/corporation/member_tracking_spec.rb +22 -0
- data/spec/lib/eve/api/calls/corporation/shareholders_spec.rb +23 -0
- data/spec/lib/eve/api/calls/corporation/standings_spec.rb +30 -0
- data/spec/lib/eve/api/calls/corporation/starbase_detail_spec.rb +32 -0
- data/spec/lib/eve/api/calls/corporation/starbase_list_spec.rb +22 -0
- data/spec/lib/eve/api/calls/corporation/titles_spec.rb +26 -0
- data/spec/lib/eve/api/calls/corporation/wallet_journal_spec.rb +22 -0
- data/spec/lib/eve/api/calls/corporation/wallet_transactions_spec.rb +22 -0
- data/spec/lib/eve/api/calls/empty_call_spec.rb +29 -0
- data/spec/lib/eve/api/calls/eve/alliance_list_spec.rb +26 -0
- data/spec/lib/eve/api/calls/eve/certificate_tree_spec.rb +18 -0
- data/spec/lib/eve/api/calls/eve/character_id_spec.rb +27 -0
- data/spec/lib/eve/api/calls/eve/conquerable_station_list_spec.rb +11 -0
- data/spec/lib/eve/api/calls/eve/error_list_spec.rb +21 -0
- data/spec/lib/eve/api/calls/eve/fac_war_stats_spec.rb +25 -0
- data/spec/lib/eve/api/calls/eve/fac_war_top_stats_spec.rb +54 -0
- data/spec/lib/eve/api/calls/eve/ref_types_spec.rb +11 -0
- data/spec/lib/eve/api/calls/eve/skill_tree_spec.rb +17 -0
- data/spec/lib/eve/api/calls/map/fac_war_systems_spec.rb +11 -0
- data/spec/lib/eve/api/calls/map/jumps_spec.rb +11 -0
- data/spec/lib/eve/api/calls/map/kills_spec.rb +11 -0
- data/spec/lib/eve/api/calls/map/sovereignty_spec.rb +11 -0
- data/spec/lib/eve/api/calls/server_status_spec.rb +28 -0
- data/spec/lib/eve/api/request_spec.rb +18 -0
- data/spec/lib/eve/api/response/error_spec.rb +13 -0
- data/spec/lib/eve/api/response_spec.rb +79 -0
- data/spec/lib/eve/api_spec.rb +13 -0
- data/spec/lib/eve/core_extensions/hash_spec.rb +23 -0
- data/spec/lib/eve/core_extensions/string_spec.rb +8 -0
- data/spec/lib/eve/trust/igb_interface_spec.rb +112 -0
- data/spec/log/development.log +0 -0
- data/spec/rcov.opts +2 -0
- data/spec/readme_spec.rb +36 -0
- data/spec/sample_api_key.yml +20 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +63 -0
- data/spec/support/behaves_like_rowset.rb +50 -0
- data/spec/support/controllers/trust_controller.rb +24 -0
- data/spec/support/jpg/mock_portrait.jpg +0 -0
- data/spec/support/mock_api_helpers.rb +46 -0
- data/spec/support/views/trust/html_and_igb.html.erb +1 -0
- data/spec/support/views/trust/html_and_igb.igb.erb +1 -0
- data/spec/support/views/trust/html_only.html.erb +1 -0
- data/spec/support/views/trust/igb_only.igb.erb +1 -0
- data/spec/support/xml/account/characters.xml +15 -0
- data/spec/support/xml/character/account_balance.xml +10 -0
- data/spec/support/xml/character/asset_list.xml +50 -0
- data/spec/support/xml/character/character_sheet.xml +65 -0
- data/spec/support/xml/character/fac_war_stats.xml +20 -0
- data/spec/support/xml/character/industry_jobs.xml +70 -0
- data/spec/support/xml/character/kill_log.xml +51 -0
- data/spec/support/xml/character/mail_messages.xml +12 -0
- data/spec/support/xml/character/mailing_lists.xml +12 -0
- data/spec/support/xml/character/market_orders.xml +11 -0
- data/spec/support/xml/character/medals.xml +13 -0
- data/spec/support/xml/character/research.xml +13 -0
- data/spec/support/xml/character/skill_in_training.xml +14 -0
- data/spec/support/xml/character/skill_not_in_training.xml +7 -0
- data/spec/support/xml/character/skill_queue.xml +11 -0
- data/spec/support/xml/character/standings.xml +32 -0
- data/spec/support/xml/character/wallet_journal.xml +39 -0
- data/spec/support/xml/character/wallet_transactions.xml +44 -0
- data/spec/support/xml/corporation/account_balance.xml +15 -0
- data/spec/support/xml/corporation/asset_list.xml +50 -0
- data/spec/support/xml/corporation/container_log.xml +32 -0
- data/spec/support/xml/corporation/fac_war_stats.xml +19 -0
- data/spec/support/xml/corporation/industry_jobs.xml +70 -0
- data/spec/support/xml/corporation/kill_log.xml +51 -0
- data/spec/support/xml/corporation/market_orders.xml +37 -0
- data/spec/support/xml/corporation/medals.xml +8 -0
- data/spec/support/xml/corporation/member_corporation_sheet.xml +51 -0
- data/spec/support/xml/corporation/member_medals.xml +10 -0
- data/spec/support/xml/corporation/member_security.xml +21 -0
- data/spec/support/xml/corporation/member_security_log.xml +55 -0
- data/spec/support/xml/corporation/member_tracking.xml +18 -0
- data/spec/support/xml/corporation/non_member_corporation_sheet.xml +30 -0
- data/spec/support/xml/corporation/shareholders.xml +11 -0
- data/spec/support/xml/corporation/standings.xml +33 -0
- data/spec/support/xml/corporation/starbase_detail.xml +33 -0
- data/spec/support/xml/corporation/starbase_list.xml +17 -0
- data/spec/support/xml/corporation/titles.xml +34 -0
- data/spec/support/xml/corporation/wallet_journal.xml +40 -0
- data/spec/support/xml/corporation/wallet_transactions.xml +12 -0
- data/spec/support/xml/errors/106.xml +5 -0
- data/spec/support/xml/errors/516.xml +5 -0
- data/spec/support/xml/eve/alliance_list.xml +22 -0
- data/spec/support/xml/eve/certificate_tree.xml +49 -0
- data/spec/support/xml/eve/character_id.xml +15 -0
- data/spec/support/xml/eve/conquerable_station_list.xml +24 -0
- data/spec/support/xml/eve/error_list.xml +78 -0
- data/spec/support/xml/eve/fac_war_stats.xml +31 -0
- data/spec/support/xml/eve/fac_war_top_stats.xml +238 -0
- data/spec/support/xml/eve/ref_types.xml +105 -0
- data/spec/support/xml/eve/skill_tree.xml +52 -0
- data/spec/support/xml/map/fac_war_systems.xml +180 -0
- data/spec/support/xml/map/jumps.xml +166 -0
- data/spec/support/xml/map/kills.xml +191 -0
- data/spec/support/xml/map/sovereignty.xml +20 -0
- data/spec/support/xml/rowset_with_mismatched_attributes.xml +6 -0
- data/spec/support/xml/server/server_status.xml +9 -0
- metadata +310 -2
@@ -0,0 +1,19 @@
|
|
1
|
+
module Eve
|
2
|
+
module Errors
|
3
|
+
# 9xx - Miscellaneous
|
4
|
+
class MiscellaneousError < StandardError; end
|
5
|
+
|
6
|
+
module MiscellaneousErrors
|
7
|
+
# 900 - Beta in progress, access denied.
|
8
|
+
class BetaInProgress < MiscellaneousError; end
|
9
|
+
# 901 - Web site database temporarily disabled.
|
10
|
+
class SiteDatabaseDisabled < MiscellaneousError; end
|
11
|
+
# 902 - EVE backend database temporarily disabled.
|
12
|
+
class BackendDatabaseDisabled < MiscellaneousError; end
|
13
|
+
# 903 - Rate limited [#]: please obey all cachedUntil timers.
|
14
|
+
class RateLimited < MiscellaneousError; end
|
15
|
+
# 999 - User forced test error condition.
|
16
|
+
class TestErrorForced < MiscellaneousError; end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Eve
|
2
|
+
module Errors
|
3
|
+
# 1xx - User Input Error
|
4
|
+
class UserInputError < StandardError; end
|
5
|
+
|
6
|
+
module UserInputErrors
|
7
|
+
# 100 - Expected beforeRefID = 0: wallet not previously loaded.
|
8
|
+
class WalletNotLoaded < UserInputError; end
|
9
|
+
# 101 - Wallet exhausted: retry after #.
|
10
|
+
class WalletExhausted < UserInputError; end
|
11
|
+
# 102 - Expected beforeRefID [#], got [#]: wallet previously loaded.
|
12
|
+
class WalletPreviouslyLoaded < UserInputError; end
|
13
|
+
# 103 - Already returned one week of data: retry after #.
|
14
|
+
class RetryLater < UserInputError; end
|
15
|
+
# 104 - GetAccountByKey(#): key not found.
|
16
|
+
class KeyNotFound < UserInputError; end
|
17
|
+
# 105 - Invalid characterID.
|
18
|
+
class InvalidCharacterID < UserInputError; end
|
19
|
+
# 106 - Must provide userID parameter for authentication.
|
20
|
+
class MissingUserID < UserInputError; end
|
21
|
+
# 107 - Invalid beforeRefID provided.
|
22
|
+
class InvalidBeforeRefID < UserInputError; end
|
23
|
+
# 108 - Invalid accountKey provided.
|
24
|
+
class InvalidAccountKey < UserInputError; end
|
25
|
+
# 109 - Invalid accountKey: must be in the range 1000 to 1006.
|
26
|
+
class AccountKeyOutOfBounds < UserInputError; end
|
27
|
+
# 110 - Invalid beforeTransID provided.
|
28
|
+
class InvalidBeforeTransID < UserInputError; end
|
29
|
+
# 111 - '#' is not a valid integer.
|
30
|
+
class InvalidInteger < UserInputError; end
|
31
|
+
# 112 - Version mismatch.
|
32
|
+
class VersionMismatch < UserInputError; end
|
33
|
+
# 113 - Version escalation is not allowed at this time.
|
34
|
+
class VersionEscalationNotAllowed < UserInputError; end
|
35
|
+
# 114 - Invalid itemID provided.
|
36
|
+
class InvalidItemID < UserInputError; end
|
37
|
+
# 115 - Assets already downloaded: retry after #.
|
38
|
+
class AssetsAlreadyDownloaded < UserInputError; end
|
39
|
+
# 116 - Industry jobs already downloaded: retry after #.
|
40
|
+
class IndustryJobsAlreadyDownloaded < UserInputError; end
|
41
|
+
# 117 - Market orders already downloaded: retry after #.
|
42
|
+
class MarketOrdersAlreadyDownloaded < UserInputError; end
|
43
|
+
# 118 - Expected beforeKillID = 0: wallet not previously loaded.
|
44
|
+
class KillsNotLoaded < UserInputError; end
|
45
|
+
# 119 - Kills exhausted: retry after #.
|
46
|
+
class KillsExhausted < UserInputError; end
|
47
|
+
# 120 - Expected beforeKillID [#] but supplied [#]: kills previously loaded.
|
48
|
+
class KillsPreviouslyLoaded < UserInputError; end
|
49
|
+
# 121 - Invalid beforeKillID provided.
|
50
|
+
class InvalidBeforeKillID < UserInputError; end
|
51
|
+
# 122 - Invalid or missing list of names.
|
52
|
+
class InvalidNameList < UserInputError; end
|
53
|
+
# 123 - Invalid or missing list of IDs.
|
54
|
+
class InvalidIDList < UserInputError; end
|
55
|
+
# 124 - Character not enlisted in Factional Warfare.
|
56
|
+
class CharacterNotEnlisted < UserInputError; end
|
57
|
+
# 125 - Corporation not enlisted in Factional Warfare.
|
58
|
+
class CorporationNotEnlisted < UserInputError; end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
@@ -0,0 +1,196 @@
|
|
1
|
+
module Eve
|
2
|
+
# In addition to the helpers listed below, this library also exposes the "igb" method as described in
|
3
|
+
# Eve::Trust.
|
4
|
+
module JavascriptHelper
|
5
|
+
# Returns the numeric type ID for a string, so you don't have to manage "magic numbers" in your application.
|
6
|
+
# The argument can be a string or a symbol, and is case insensitive. Underscores will be converted to spaces.
|
7
|
+
#
|
8
|
+
# Examples:
|
9
|
+
# type_id('alliance') # => 16159
|
10
|
+
# type_id('character') # => 1377
|
11
|
+
# type_id('corporation') # => 2
|
12
|
+
# type_id('constellation') # => 4
|
13
|
+
# type_id('region') # => 3
|
14
|
+
# type_id('Solar System') # => 5
|
15
|
+
# type_id(:solar_system) # => 5
|
16
|
+
# type_id(:station) # => 3867
|
17
|
+
#
|
18
|
+
def type_id(which)
|
19
|
+
which = which.to_s.humanize unless which.kind_of?(String)
|
20
|
+
which.downcase!
|
21
|
+
case which
|
22
|
+
when 'alliance' then 16159
|
23
|
+
when 'character' then 1377
|
24
|
+
when 'corporation' then 2
|
25
|
+
when 'constellation' then 4
|
26
|
+
when 'region' then 3
|
27
|
+
when 'solar system', 'solarsystem' then 5
|
28
|
+
when 'station' then 3867
|
29
|
+
else raise ArgumentError, "Unknown type: #{which}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Creates a hyperlink that results in opening the client's EVE mail inbox.
|
34
|
+
def link_to_evemail(text, *args)
|
35
|
+
link_to_function(text, "CCPEVE.openEveMail()", *args)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Creates a hyperlink that results in the "show info" dialog being displayed on the client's screen.
|
39
|
+
# If item_id is given, the show info window will open for that item.
|
40
|
+
#
|
41
|
+
# type_id (Number)
|
42
|
+
# Type ID of item to show info on.
|
43
|
+
# item_id (Number)
|
44
|
+
# Optional item ID of specific item of type type_id to show info on. This is required for specific types of
|
45
|
+
# items, such as solar systems, stations, regions, and constellations.
|
46
|
+
#
|
47
|
+
def link_to_info(text, type_id, item_id = nil, *args)
|
48
|
+
function = "CCPEVE.showInfo(#{type_id.inspect}"
|
49
|
+
function.concat ", #{item_id.inspect}" if item_id
|
50
|
+
function.concat ")"
|
51
|
+
link_to_function text, function, *args
|
52
|
+
end
|
53
|
+
|
54
|
+
# Creates a hyperlink that results in opening the preview window for type_id.
|
55
|
+
#
|
56
|
+
# type_id (Number)
|
57
|
+
# Type ID of item to preview.
|
58
|
+
#
|
59
|
+
def link_to_preview(text, type_id, *args)
|
60
|
+
link_to_function text, "CCPEVE.showPreview(#{type_id.inspect})", *args
|
61
|
+
end
|
62
|
+
|
63
|
+
# Creates a hyperlink that results in showing the route to the destination_id from the source_id.
|
64
|
+
# If source_id is not given, the source system is taken to be the system the user is currently in.
|
65
|
+
#
|
66
|
+
def link_to_route(text, destination_id, source_id = nil, *args)
|
67
|
+
function = "CCPEVE.showRouteTo(#{destination_id.inspect}"
|
68
|
+
function.concat ", #{source_id.inspect}" if source_id
|
69
|
+
function.concat ")"
|
70
|
+
link_to_function text, function, *args
|
71
|
+
end
|
72
|
+
|
73
|
+
# Creates a hyperlink that results in opening the map. If system_id is given, the map will focus on that system.
|
74
|
+
#
|
75
|
+
# system_id (Number)
|
76
|
+
# Optional ID of solar system to focus map on.
|
77
|
+
#
|
78
|
+
def link_to_map(text, system_id = nil, *args)
|
79
|
+
link_to_function text, "CCPEVE.showMap(#{system_id ? system_id.inspect : ''})", *args
|
80
|
+
end
|
81
|
+
|
82
|
+
# Creates a hyperlink that results in opening the fitting window and displays the fitting represented by fitting.
|
83
|
+
#
|
84
|
+
# fitting (String)
|
85
|
+
# A Ship DNA string.
|
86
|
+
#
|
87
|
+
# See http://wiki.eveonline.com/en/wiki/Ship_DNA for details
|
88
|
+
def link_to_fitting(text, ship_dna_string, *args)
|
89
|
+
link_to_function text, "CCPEVE.showFitting(#{ship_dna_string.inspect})", *args
|
90
|
+
end
|
91
|
+
|
92
|
+
# Creatse a hyperlink that results in opening the contract window and displaying the contract represented by the
|
93
|
+
# contract_id argument. Contracts are, however, assigned per-solar-system, and so a solar_system_id must also be
|
94
|
+
# provided.
|
95
|
+
#
|
96
|
+
# solar_system_id (Number)
|
97
|
+
# The ID number of the solar system in which the contract is located.
|
98
|
+
# contract_id (Number)
|
99
|
+
# The ID number of the contract to display.
|
100
|
+
def link_to_contract(text, solar_system_id, contract_id, *args)
|
101
|
+
link_to_function text, "CCPEVE.showContract(#{solar_system_id.inspect}, #{contract_id.inspect})", *args
|
102
|
+
end
|
103
|
+
|
104
|
+
# Creates a hyperlink which results in opening the market details window and displays the information about the
|
105
|
+
# item represented by type_id.
|
106
|
+
#
|
107
|
+
# typeID (Number)
|
108
|
+
# Type ID to display market details about
|
109
|
+
#
|
110
|
+
def link_to_market_details(text, type_id, *args)
|
111
|
+
link_to_function text, "CCPEVE.showMarketDetails(#{type_id.inspect})", *args
|
112
|
+
end
|
113
|
+
|
114
|
+
# Produces a hyperlink that will result in a pop-up a trust prompt in the client, allowing the user to either
|
115
|
+
# grant the trust request, ignore it, or always ignore trust requests from your site.
|
116
|
+
#
|
117
|
+
# trust_url (String)
|
118
|
+
# This is a fully-qualified domain name and path (e.g. http://wiki.eveonline.com/w/) to which your site would
|
119
|
+
# like the user to grant trust.
|
120
|
+
#
|
121
|
+
# The page will not be automatically refreshed if the user grants the trust request. Trust will take effect the
|
122
|
+
# next time the user refreshes the page, or navigates within the site.
|
123
|
+
#
|
124
|
+
# Note that trust_url is processed and only the protocol, domain and path will be used from it. If you supply a
|
125
|
+
# query string or anchor, they will be discarded. It is recommended that you primarily pass in only
|
126
|
+
# fully-qualified domain names without paths (e.g. http://wiki.eveonline.com instead of
|
127
|
+
# http://wiki.eveonline.com/w/index.php), as this avoids pestering the user for trust on every page.
|
128
|
+
#
|
129
|
+
def link_to_trust_request(text, trust_url = "http://#{request.host}/", *args)
|
130
|
+
trust_url = url_for(trust_url.merge(:only_path => false)) if trust_url.kind_of?(Hash)
|
131
|
+
link_to_function text, "CCPEVE.requestTrust(#{trust_url.inspect})", *args
|
132
|
+
end
|
133
|
+
|
134
|
+
# This will generate a method call that produces a pop-up a trust prompt in the client, allowing the user to
|
135
|
+
# either grant the trust request, ignore it, or always ignore trust requests from your site.
|
136
|
+
#
|
137
|
+
# trust_url (String)
|
138
|
+
# This is a fully-qualified domain name and path (e.g. http://wiki.eveonline.com/w/) to which your site would
|
139
|
+
# like the user to grant trust.
|
140
|
+
#
|
141
|
+
# The page will not be automatically refreshed if the user grants the trust request. Trust will take effect the
|
142
|
+
# next time the user refreshes the page, or navigates within the site.
|
143
|
+
#
|
144
|
+
# Note that trust_url is processed and only the protocol, domain and path will be used from it. If you supply a
|
145
|
+
# query string or anchor, they will be discarded. It is recommended that you primarily pass in only
|
146
|
+
# fully-qualified domain names without paths (e.g. http://wiki.eveonline.com instead of
|
147
|
+
# http://wiki.eveonline.com/w/index.php), as this avoids pestering the user for trust on every page.
|
148
|
+
#
|
149
|
+
def request_trust(trust_url = "http://#{request.host}/", *args)
|
150
|
+
trust_url = url_for(trust_url.merge(:only_path => false)) if trust_url.kind_of?(Hash)
|
151
|
+
javascript_tag "CCPEVE.requestTrust(#{trust_url.inspect});", *args
|
152
|
+
end
|
153
|
+
|
154
|
+
# Sets the client's autopilot destination to the specified solar system.
|
155
|
+
#
|
156
|
+
# solar_system_id (Number)
|
157
|
+
# The numerical identifier of the solar system to which you wish to set the client's autopilot destination.
|
158
|
+
#
|
159
|
+
# This method requires that the user grant Trust to the calling site.
|
160
|
+
def link_to_destination(text, solar_system_id, *args)
|
161
|
+
link_to_function text, "CCPEVE.setDestination(#{solar_system_id.inspect})", *args
|
162
|
+
end
|
163
|
+
|
164
|
+
# Adds the specified solar system to the end of the client's autopilot route. If the solar system is already in
|
165
|
+
# the route, no changes are made and the method fails silently.
|
166
|
+
#
|
167
|
+
# solar_system_id (Number)
|
168
|
+
# The numerical identifier of the solar system which you wish to append to the client's autopilot route.
|
169
|
+
#
|
170
|
+
# This method requires that the user grant Trust to the calling site.
|
171
|
+
def link_to_waypoint(text, solar_system_id, *args)
|
172
|
+
link_to_function text, "CCPEVE.addWaypoint(#{solar_system_id.inspect})", *args
|
173
|
+
end
|
174
|
+
|
175
|
+
# Causes the user to attempt to join the named channel. Normal channel access control rules apply. If the user is
|
176
|
+
# unable to join the channel, the method fails silently.
|
177
|
+
#
|
178
|
+
# channel_name (String)
|
179
|
+
# The name of the channel which the user will join.
|
180
|
+
#
|
181
|
+
# This method requires that the user grant Trust to the calling site.
|
182
|
+
def link_to_channel(text, channel_name, *args)
|
183
|
+
link_to_function text, "CCPEVE.joinChannel(#{channel_name.inspect})", *args
|
184
|
+
end
|
185
|
+
|
186
|
+
# Causes the user to subscribe to the named mailing list.
|
187
|
+
#
|
188
|
+
# mailing_list_name (String)
|
189
|
+
# The name of the mailing list which the user will join.
|
190
|
+
#
|
191
|
+
# This method requires that the user grant Trust to the calling site.
|
192
|
+
def link_to_mailing_list(text, mailing_list_name, *args)
|
193
|
+
link_to_function text, "CCPEVE.joinMailingList(#{mailing_list_name.inspect})", *args
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
data/lib/eve/trust.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'eve/trust/controller_helpers'
|
2
|
+
require 'eve/trust/igb_interface'
|
3
|
+
|
4
|
+
module Eve
|
5
|
+
# == Trust
|
6
|
+
# The primary purpose for the ActionController is to figure out which View should be rendered, and what data to send
|
7
|
+
# to that View. In keeping with this paradigm, a few helper methods have been added that allow you to establish
|
8
|
+
# trust with the In-Game Browser (IGB), which in turn provides access to more useful information such as the player's
|
9
|
+
# current location. To establish trust with a compatible browser, simply add one line to your controller:
|
10
|
+
#
|
11
|
+
# class AnyController < ApplicationController
|
12
|
+
# requires_trust
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# This will cause the in-game browser to prompt the user, asking him/her to complete the handshake. If they refuse,
|
16
|
+
# the page will not load. To establish _optional_ trust -- that is, to allow the page to load even if the user hasn't
|
17
|
+
# granted the trust request -- you can use +prefers_trust+ instead:
|
18
|
+
#
|
19
|
+
# class AnyController < ApplicationController
|
20
|
+
# prefers_trust
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# Both methods also accept a custom trust request message that will be shown to the user when they are prompted:
|
24
|
+
#
|
25
|
+
# class AnyController < ApplicationController
|
26
|
+
# prefers_trust "To take full advantage of the features on this site, please grant this trust request."
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# == IGB Headers
|
30
|
+
# After trust has been established, the IGB sends additional content headers to the server with every request. These
|
31
|
+
# headers contain the most up-to-date information regarding the current user, his/her location, his/her character ID,
|
32
|
+
# and so on. The character ID could, for example, be used in conjunction with Eve::API to show the character's
|
33
|
+
# portrait in a forum.
|
34
|
+
#
|
35
|
+
# To gain access to this extra information, use the +igb+ method:
|
36
|
+
#
|
37
|
+
# class AnyController < ApplicationController
|
38
|
+
# . . .
|
39
|
+
# def index
|
40
|
+
# if igb? && igb.trusted? # if the client is using the IGB and trust has been established
|
41
|
+
# @solar_system = igb.solar_system_name # then make a note of the current solar system
|
42
|
+
# @character_id = igb.character_id # and the character ID
|
43
|
+
# else
|
44
|
+
# . . . # handle a non-IGB browser such as Internet Explorer or Firefox.
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# To find out which methods are exposed by the +igb+ method, take a look at Eve::Trust::IgbInterface.
|
49
|
+
#
|
50
|
+
# == View Format
|
51
|
+
# In Rails, the View is usually rendered in HTML format. That means the view template is usually called
|
52
|
+
# +some_action_name.html.erb+ , where "some_action_name" is the name of the current action and "html" is the file
|
53
|
+
# format. This library exposes a new format, "igb", which allows you to render an IGB-specific response. This response
|
54
|
+
# is expected to be in IGB-compatible HTML format. Here's an example of what an IGB file might look like:
|
55
|
+
#
|
56
|
+
# <%=link_to_evemail "Check Your Mail!"%>
|
57
|
+
# <%if igb.trusted?%>
|
58
|
+
# <p>Thanks for your trust! I see you're currently in <%=igb.solar_system_name%>.</p>
|
59
|
+
# <p>Here's some information about our secret headquarters:</p>
|
60
|
+
# <ul>
|
61
|
+
# <li><%=link_to_route "Click For Directions", "Jita"%></li>
|
62
|
+
# <li><%=link_to_map "Show On Map", "Jita"%></li>
|
63
|
+
# </ul>
|
64
|
+
# <%end%>
|
65
|
+
#
|
66
|
+
# For more information about the various helpers available to your IGB-specific views, take a look at
|
67
|
+
# Eve::Helpers::JavascriptHelper.
|
68
|
+
#
|
69
|
+
# If the client is using the EVE In-Game Browser, then the "action_name.igb.erb" file will be automatically used,
|
70
|
+
# provided it exists. If the matching file is not found, then "action_name.html.erb" will be used in its place, just
|
71
|
+
# as if the client were using any other browser such as Internet Explorer or Firefox. You can also explicitly require
|
72
|
+
# that the .igb file be rendered using the +set_igb+ method:
|
73
|
+
#
|
74
|
+
# class AnyController < ApplicationController
|
75
|
+
# before_filter :check_for_igb_requirement
|
76
|
+
# private
|
77
|
+
# def check_for_igb_requirement
|
78
|
+
# if (some_condition)
|
79
|
+
# set_igb # force the IGB template for this action to be rendered
|
80
|
+
# end
|
81
|
+
# end
|
82
|
+
# end
|
83
|
+
#
|
84
|
+
module Trust
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module Eve
|
2
|
+
module Trust
|
3
|
+
module ControllerHelpers
|
4
|
+
def self.included(base)
|
5
|
+
base.instance_eval do
|
6
|
+
hide_action :trust_message, :trust_message=, :detect_igb, :template_exists?,
|
7
|
+
:set_igb_or_default, :default_template_exists?, :mock_methods_for_testing!,
|
8
|
+
:igb, :igb?, :set_igb, :require_trust, :prefer_trust, :deliver_trust_message
|
9
|
+
class_attribute :trust_message
|
10
|
+
self.trust_message ||= "This web site is requesting your trust."
|
11
|
+
|
12
|
+
delegate :igb?, :to => :igb
|
13
|
+
before_filter :detect_igb
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def requires_trust(message = trust_message)
|
17
|
+
self.trust_message = message if message != trust_message
|
18
|
+
before_filter :require_trust
|
19
|
+
end
|
20
|
+
|
21
|
+
def prefers_trust(message = trust_message)
|
22
|
+
self.trust_message = message if message != trust_message
|
23
|
+
before_filter :prefer_trust
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def igb
|
30
|
+
@igb ||= Eve::Trust::IgbInterface.new(request)
|
31
|
+
end
|
32
|
+
|
33
|
+
def require_trust(trust_message = self.class.trust_message)
|
34
|
+
if igb? && !igb.trusted?
|
35
|
+
render :text => "<body onload=\"CCPEVE.requestTrust('http://#{request.host_with_port}')\">", :layout => false
|
36
|
+
end
|
37
|
+
true
|
38
|
+
end
|
39
|
+
|
40
|
+
def prefer_trust(trust_message = self.class.trust_message)
|
41
|
+
if igb? && !igb.trusted?
|
42
|
+
deliver_trust_message(trust_message)
|
43
|
+
end
|
44
|
+
true
|
45
|
+
end
|
46
|
+
|
47
|
+
def deliver_trust_message(trust_message = self.class.trust_message)
|
48
|
+
trust_uri = "http://#{request.host_with_port}/"
|
49
|
+
headers['Eve.trustme'] = "#{trust_uri}::#{trust_message}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def detect_igb
|
53
|
+
if igb.igb?
|
54
|
+
set_igb_or_default
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def set_igb_or_default
|
59
|
+
if default_template_exists? :igb
|
60
|
+
set_igb
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def set_igb
|
65
|
+
request.format = :igb
|
66
|
+
igb
|
67
|
+
end
|
68
|
+
|
69
|
+
unless defined?(default_template_name)
|
70
|
+
def default_template_name
|
71
|
+
# FIXME: I didn't check how Rails3 actually decides which template to render --
|
72
|
+
# we should really follow the same rules so we don't break anything unintentionally.
|
73
|
+
action_name
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def default_template_exists?(format = request.format)
|
78
|
+
formats = lookup_context.formats
|
79
|
+
lookup_context.formats = [format]
|
80
|
+
lookup_context.exists?(default_template_name, controller_path)
|
81
|
+
ensure
|
82
|
+
lookup_context.formats = formats
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|