-
Notifications
You must be signed in to change notification settings - Fork 499
Add sharing feature #410
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
Open
abuisman
wants to merge
13
commits into
ankane:master
Choose a base branch
from
abuisman:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add sharing feature #410
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9b71178
Add sharing feature to queries
abuisman 49eabe1
Make tests of sharing independent of ENV
abuisman cf79e56
Add README for sharing
abuisman 5a38181
Correct id on google sheet sharing input
abuisman 08a9e73
Remove placeholder bootstrap buttons from modal
abuisman a3e9df2
Merge pull request #1 from ankane/master
abuisman cda2ffd
Use api_key
abuisman 1e2628a
Fix dumb mistake of not creating the correct urls
abuisman bab1890
Replace api key with token per query
abuisman 78cbf77
Merge branch 'master' into master
abuisman 6085eb0
Check for utf-8 in type
abuisman f73dad8
Fix generated share link
abuisman 88db24b
Merge branch 'ankane:master' into master
abuisman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <div class="modal fade" id="sharingModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> | ||
| <div class="modal-dialog" role="document"> | ||
| <div class="modal-content"> | ||
| <div class="modal-header"> | ||
| <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | ||
| <h4 class="modal-title" id="myModalLabel">Sharing</h4> | ||
| </div> | ||
| <div class="modal-body"> | ||
| Below are some shareable links to this query. Copy and share them. | ||
|
|
||
| Anyone with these urls can access the results of this query! | ||
|
|
||
| <div class="form-group"> | ||
| <label for="csvShare">CSV</label> | ||
| <input type="text" class="form-control" id="csvShare" readonly value="<%= Blazer.sharing.url_for(@query.id, request.url, format: 'csv') %>"> | ||
| </div> | ||
|
|
||
| <div class="form-group"> | ||
| <label for="csvShare">Google sheets</label> | ||
| <input type="text" class="form-control" id="googleShare" readonly value='=IMPORTDATA("<%= Blazer.sharing.url_for(@query.id, request.url, format: 'csv') %>")'> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| module Blazer | ||
| class Sharing | ||
| attr_accessor :api_key, :path | ||
|
|
||
| def initialize(api_key: ENV.fetch('BLAZER_DOWNLOAD_API_KEY', nil), path: '/blazer_share') | ||
| @api_key = api_key | ||
| @path = path.sub(/\/$/, '') # Strip trailing / | ||
| end | ||
|
|
||
| def route_path | ||
| @route_path ||= "#{path}/:token/:query_id" | ||
| end | ||
|
|
||
| def to_controller | ||
| 'blazer/queries#share' | ||
| end | ||
|
|
||
| def query_token(query_id) | ||
| Digest::SHA1.hexdigest("#{query_id}-#{api_key}") | ||
|
abuisman marked this conversation as resolved.
Outdated
|
||
| end | ||
|
|
||
| def enabled? | ||
| api_key.present? | ||
| end | ||
|
|
||
| def share_path(query_id, format: nil) | ||
| "#{path}/#{query_token(query_id)}/#{query_id}#{".#{format}" if format}" | ||
| end | ||
|
|
||
| def url_for(query_id, current_url, format: 'csv') | ||
| url = URI.parse(current_url) | ||
| url.path = share_path(query_id, format: format) | ||
| url.to_s | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.