Giter Site home page Giter Site logo

art-institute-of-chicago / browser-extension Goto Github PK

View Code? Open in Web Editor NEW
14.0 5.0 6.0 1.41 MB

Browser extension to view a random artwork from our collection in a new browser tab

License: GNU Affero General Public License v3.0

HTML 5.69% JavaScript 74.77% CSS 19.54%
chrome-extension browser-extension

browser-extension's Introduction

.Art Institute of Chicago

Art Institute of Chicago Browser Extension

A browser extension that presents a random work of art from the Art Institute of Chicago's collection with each new tab.

In September 2019, the Art Institute of Chicago (AIC) launched its data API for public use. The API provides information and access to over 100,000 artworks.

Using the data API and IIIF's image API, AIC's browser extension presents an artwork from the museum's collection in your browser every time a new tab is opened. The extension focuses on selecting from over 50,000 works marked for public domain use.

For public use, this extension is available in the Chrome Web Store. If you'd like to install the plugin for local development, follow the instructions below.

This repo serves as an example of using the Art Institute of Chicago's data API.

Screenshot of the extension in action

Features

  • Presents artwork from the Art Institute's collection in new browser tab
  • Demonstrates use of the Art Institute's data API

Requirements

Chrome browser in Developer Mode

Installing

Clone or download the project:

git clone https://github.com/art-institute-of-chicago/browser-extension.git
cd browser-extension
  • If you downloaded a zip file from GitHub, unzip the package
  • From Chrome menu choose Window - Extensions
  • Toggle on "Developer Mode"
  • Click "Load Unpacked"
  • Select the browser-extension folder you cloned
  • Optionally toggle "Developer Mode" off

Screenshot of Chrome Windows menu with Extensions highlighted

Screenshot of the Extensions window

Configuration

In script.js, you'll find the query that fetches a random artwork:

let timeStamp = Math.floor(Date.now() / 1000);
    let artworkRequest = {
        "resources": "artworks",
        "fields": [
            "id",
            "title",
            "artist_title",
            "image_id",
            "date_display",
	    "thumbnail"
        ],
        "boost": false,
        "limit": 1,
        "query": {
            "function_score": {
                "query": {
                    "bool": {
                            "must": [
                                {
                                    "term": {
                                        "is_public_domain": true
                                    },
                                },
                                {
                                    "exists": {
                                        "field": "image_id",
                                    },
                                },
                            ],
                        },
                    }
                },
                "boost_mode": "replace",
                "random_score": {
                    "field": "id",
                    "seed": timeStamp
                }
            }
        }
    };

Contributing

We encourage your contributions. Please fork this repository and make your changes in a separate branch. To better understand how we organize our code, please review our version control guidelines.

# Clone the repo to your computer
git clone [email protected]:your-github-account/browser-extension.git

# Enter the folder that was created by the clone
cd browser-extension

# Install dependencies (we use Yarn)
yarn install --frozen-lockfile

# Start a feature branch
git checkout -b feature/good-short-description

# ... make some changes, commit your code

# Push your branch to GitHub
git push origin feature/good-short-description

On github.com, create a Pull Request to merge your changes into our develop branch.

This project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

We welcome bug reports and questions under GitHub's Issues. For other concerns, you can reach our engineering team at [email protected]

Code Formatting

We use Prettier to perform standard formatting across all the JS, CSS, HTML, and Markdown files in the project. If you've installed the project dependencies correctly with Yarn, a pre-commit hook that formats all your staged files should automatically execute when you run git commit.

Alternatively, you could manually run Prettier like so:

yarn prettier --write "$(pwd)/**/*.(js|css|html|md)

Acknowledgements

AIC's browser extension was conceived in the Experience Design department during the 2018 internship program, Diversifying Art Museum Leadership Initiative (DAMLI). Thanks to our intern, Abdur Khan, for helping make this project possible.

Additional thanks to Mark Dascoli, Illya Moskvin, Tina Shah, Kirsten Southwell, and nikhil trivedi, for helping complete version 1 of the browser extension.

Inspiration for this project came from the following browser extension projects:

The following tutorial helped us get started: How to Create and Publish a Chrome Extension in 20 minutes from freeCodeCamp.org

Licensing

This project is licensed under the GNU Affero General Public License Version 3.

browser-extension's People

Contributors

akhan139 avatar ctcpip avatar dependabot[bot] avatar dylanirlbeck avatar illyamoskvin avatar nikhiltri avatar surreal8 avatar zachgarwood avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

browser-extension's Issues

Add alt tag

Add alt tag to images/canvas in openseadragon

Add time intervals for more seed collision

From prior conversation:

We could make sure that there's more overlap between the results provided to different users. For example, right now, we are using the current timestamp in seconds for the seed. Anyone who launches or refreshes new tab at the same second should see the same image. Something we could consider doing is to sort of... create a scale of time intervals, and choose the biggest one based on when the user last accessed the new tab. (Assuming we can store that in local storage.) For example, let's say that the biggest entry on our scale is a half-hour. If it's been more than 30 min since the last time the user launched new tab, we will take the current timestamp and floor it to the nearest half-hour, and use that as the seed. So if the three of us launched new tab at 10:10, 10:15, and 10:20 AM respectively, and if it's been more than a half-hour since the last time each of us launched new tab, we should all see the same image. Then, let's say that the next entry on our scale is 15 min. If it's been less than a half-hour since you launched new tab, we check if it's also been less than 15 min. If not, we floor the timestamp to the nearest 15 min, and use that as the seed. If yes, we go down to our next smallest interval, say, 10 min. Same deal. Then, down to 5 min, to 1 min, to 30 sec, and etc., until we arrive at our current setting of one second.

This should account for normal usage, as well as cases where users are rapidly refreshing the page to see new images.

Perform query and load images for future new tabs

Currently, we query our API and download images when a new tab is opened. Instead, what we can do is to save our query results for next time in LocalStorage. If a saved query result already exists, we show that data, and query a result for next time. This way, we don't necessarily need to query the API whenever a new tab is opened before displaying stuff.

Likewise, after OpenSeadragon renders all tiles on initial load, we can create a new OSD instance, one that might be hidden using opacity or other tricks. By doing this, we can download some or all of the necessary images into the browser cache. Even if not all of the images are downloaded, we've made progress towards future downloads. Some tiles might have made it into the browser cache, while others might have made it into the IIIF cache, or the CDN cache, if not necessarily into the user's browser.

If we'd like, we can do this preload trick for not just the next new tab, but for some predefined number of them at a time. The longer a new tab is opened, the further ahead we can preload.

Remove CC0 button

Everything displayed by default is CC0, but the CC0 logo takes too much visual focus away from the content.

Chrome Web Store requirements

here’s what we need to publish to the store:

  1. favicon/icon - 128x128
  2. Summary sentence (we’ll grab from our github)
  3. Screenshots (sizes mentioned below)
  4. Tiles (sizes mentioned below)

Tile sizes:
Small tile - 440x280:
Large tile - 920x680: (optional)
Marquee - 1400x560: (optional)

Screenshot:
1280x800 or 640x400

Implement design feedback

See comment on #24. Additionally:

  • Reduce font size in tombstone
  • Give tombstone more breathing room from edges
  • Use outline version of logo
  • Move logo to top-left
  • Don't use artist_display, use artist_titles with creation date(s)

Implement date filter

Allow users to filter by a range of dates (i.e. 1850 to 2000).

@IllyaMoskvin I'm going to create separate tickets to help scope out the work better.

Show current filters on frontend

Blocked by #19. Related to #45 and #27. Proposed by @dylanirlbeck in #45:

It'd be nice to also have a banner of some sort that indicates if the extension is applying the filter, and if so what the filter is for (e.g. Black History Month).

We chatted about this internally, and we think that a good way to go would be to have some sort of hamburger icon in the top-right corner. When activated, it should open a drop-down menu with a list of filters. This menu is informational: these filters do not need to be editable from within the menu directly. At the bottom of the menu, there should be a link to the plugin's settings, where the user can edit the filters.

We might work with our designers on a mockup for this functionality, but it's not a blocker. For anyone interested in this, once initial work on #19 is complete, this ticket is up for grabs. As long as the code is clean and works well, we can do a design pass after the functionality has been implemented.

Update query for random artwork

We recently sent this same query with some minor tweaks to another developer. Make the same changes to the query in this app:

    let timeStamp = Math.floor(Date.now() / 1000);
    let artworkRequest = {
        "resources": "artworks",
        "fields": [
            "id",
            "title",
            "artist_display",
            "image_id",
            "date_display"
        ],
        "boost": false,
        "limit": 1,
        "query": {
            "function_score": {
                "query": {
                    "constant_score" : {
                        "filter": {
                            "exists": {
                                "field": "image_id"
                            }
                        }
                    }
                },
                "boost_mode": "replace",
                "random_score": {
                    "field": "id",
                    "seed": timeStamp
                }
            }
        }
    };

Handle long titles

Long titles do not look good, overlaps image, needs to perhaps wrap...

Enforcing new code to be formatted with Prettier

As I was working though #49, it quickly became clear there is no standard formatting for the project (or at least a formatter that ships with the repo). I think it'd be nice to enforce Prettier for any new code that comes in to the repo, since that seems to be a fairly standard formatter for JS, CSS, HTML, and JSON -- all the tech this extension currently uses!

Foruntately for us, there is a GitHub action that will do exactly this, with minimal effort required on our part: https://github.com/creyD/prettier_action. There may be other GitHub actions, but this issue is more to start a discussion.

cc @IllyaMoskvin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.