-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* dev: update changelog, 2.4.1 notes libraryh3lp chat widget accessibility - label for search input fix hamburger icon aspect ratio, closes #93 darken link color for accessibility, ref #93 Instagram API update. Squashed commit.
- Loading branch information
Showing
12 changed files
with
165 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,18 @@ | ||
# Generated by Django 2.2.11 on 2020-03-25 22:59 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('instagram', '0004_insta_url'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='instagramoauthtoken', | ||
name='token', | ||
field=models.CharField(max_length=300), | ||
), | ||
] |
This file contains 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 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 |
---|---|---|
@@ -1,15 +1,19 @@ | ||
|
||
Pulls the latest Instagram post for an account, which is then used on the home page. This uses the `v1/users/self/media/recent` API ([dox](https://www.instagram.com/developer/endpoints/users/#get_users_media_recent_self)) and merely grabs the latest post available. | ||
Pulls the latest Instagram post for an account, which is then used on the home page. This uses the Instagram Basic Display API ([dox](https://developers.facebook.com/docs/instagram-basic-display-api/getting-started)) and merely grabs the latest post available. | ||
|
||
Configuration: | ||
Configuration ([these steps are a good outline](https://developers.facebook.com/docs/instagram-basic-display-api/getting-started)): | ||
|
||
- create an [Instagram API client](https://www.instagram.com/developer/clients/manage/) so you can get a client ID and set a redirect_uri | ||
- add both `INSTAGRAM_CLIENT_ID` and `INSTAGRAM_REDIRECT_URI` to your settings | ||
- run the management command, `python manage.py get_oauth_token`, copy the "access_token" parameter out of the redirect URI, then paste that back into the command prompt to save it to the database | ||
- create a Facebook app on https://developers.facebook.com | ||
- add the **Instagram** product, select "Basic Display" > **Create new app** | ||
- Fill out all the fields, though we won't use many of them. We don't have a script that programmatically uses the redirect URI; I just manually copy the code out of the URL. Note that redirect URIs apparently cannot be a straight domain like http://example.com (Facebook will append a slash like `.com/` without telling you). | ||
- add an "Instagram Test User" for the Instagram account you want to display | ||
- add the app's `INSTAGRAM_CLIENT_ID`, `INSTAGRAM_CLIENT_SECRET`, and `INSTAGRAM_REDIRECT_URI` to your settings | ||
- run the management command, `python manage.py get_oauth_token`, copy the "code" parameter out of the redirect URI (**IMPORTANT**: remove the `#\_` at the end), then paste that back into the command prompt | ||
- the script will complete a couple steps to get an OAuth access token | ||
- now when you run `python manage.py instagram` the latest gram is saved to the database | ||
- set up a cron job to run the management command above on a schedule | ||
|
||
See IG's [authentication](https://www.instagram.com/developer/authentication/) page for more. I couldn't think of an elegant way to automate renewing the token without human intervention—someone has to physically click a button on Instagram to trigger the redirect. For now, the best we can do is log an error when the OAuth token is out of date, then use `get_oauth_token` to get a new one. | ||
This whole setup process should only need to run once. Once we obtain an access token it lasts for sixty days and can be [exchanged for a fresh token](https://developers.facebook.com/docs/instagram-basic-display-api/guides/long-lived-access-tokens) which also lasts that long, meaning that the app can keep checking the expiration date and refreshing its token during a routine `python manage.py instagram` cron job. | ||
|
||
Previously, we attempted to use the undocumented https://www.instagram.com/ccalibraries/media/ and https://www.instagram.com/ccalibraries/?__a=1 URLs which returned JSON data about our Instagram account. But after multiple unannounced changes to the structure of this data, it was clear that using the Instagram API was a better decision. Unfortunately, Instagram is about to migrate to the Instagram Graph API and it sounds like it's only available for "business accounts" so it's unclear how easily we'll be able to do the same thing with the new API. But the one we're using currently should be functional until "early 2020". | ||
Previously, we attempted to use the undocumented https://www.instagram.com/ccalibraries/media/ and https://www.instagram.com/ccalibraries/?__a=1 URLs which returned JSON data about our Instagram account. But after multiple unannounced changes to the structure of this data, it was clear that using the (now defunct) Instagram API was a better decision. Unfortunately, Instagram then migrated to the Instagram Graph API which required us to rewrite the whole authentication portion of this app for a second time. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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,12 @@ | ||
// use libraryh3lp Presence API https://dev.libraryh3lp.com/presence.html | ||
fetch('https://libraryh3lp.com/presence/jid/cca-libraries-queue/chat.libraryh3lp.com/text') | ||
.then(resp => resp.text()) | ||
.then(status => { | ||
// only display if we are signed in | ||
if (status == 'available' || status == 'chat') { | ||
$('body').append('<div class="needs-js">') | ||
var x = document.createElement("script"); x.type = "text/javascript"; x.async = true; | ||
x.src = (document.location.protocol === "https:" ? "https://" : "http://") + "libraryh3lp.com/js/libraryh3lp.js?13843"; | ||
var y = document.getElementsByTagName("script")[0]; y.parentNode.insertBefore(x, y); | ||
} | ||
}) |
This file contains 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 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
1 change: 1 addition & 0 deletions
1
libraries/libraries/templates/components/search/search-input.html
This file contains 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