-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Convert image links to shortened URLs #546
Changes from 2 commits
93e3a86
1be6bc6
8facb79
2c5e3e5
eb3c901
d43264a
abe568f
0185302
12d8de9
f38808c
d21f70e
99b7c21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class TinyURL | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recommend changing the name of this class to something generic, such as |
||
def self.short(url) | ||
HTTParty.get("http://tinyurl.com/api-create.php?url=#{url}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method should rescue any exception(s) that might occur, write something to the log, and return It looks like we can just rescue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "log" that I refer to should be specific to the URL shortening service. The log should only contain exceptions - no need to log successful execution. For an example of logging exception, you could look at |
||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ | |
%br | ||
%br | ||
= t('users.show.use_this_image_link_html') | ||
= company_h_brand_url(user, company_id: company.id) | ||
= :hort_company_h_brand_url(user, company.id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
|
||
:javascript | ||
window.onload = function(){ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,8 +56,8 @@ | |
height_id: 'pom-height') | ||
%br | ||
%br | ||
= t('users.show.use_this_image_link_html') | ||
= proof_of_membership_url(user) | ||
= t('users.show.use_this_image_link_htmlsers.show.use_this_image_link_html') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be:
|
||
= short_proof_of_membership_url(user) | ||
|
||
:javascript | ||
window.onload = function(){ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two methods should be Company instance methods (hence, defined in the model file).
These methods should first determine if we already have a shortened URL for the link - if so, just return that. If not, call the service class and save the result if not
nil
.Finally, if we don't have a shortened URL for the link (because it's not in the DB and the service call fails), then just return the unshortened URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistent with above comment, we need a migration to add the shortened URL's to the DB.