Skip to content

Commit

Permalink
add basic implementation of image api playground
Browse files Browse the repository at this point in the history
  • Loading branch information
mejackreed committed Jul 13, 2017
1 parent 4db4140 commit 05adade
Show file tree
Hide file tree
Showing 13 changed files with 224 additions and 14 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
"license": "MIT",
"dependencies": {
"bootstrap": "4.0.0-alpha.6",
"prop-types": "^15.5.10",
"react": "^15.6.1",
"react-addons-update": "^15.6.0",
"react-dom": "^15.6.1"
"react-dom": "^15.6.1",
"react-image": "^1.0.1"
},
"devDependencies": {
"babel-core": "^6.25.0",
Expand Down
5 changes: 3 additions & 2 deletions src/_data/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
name: What is IIIF?
- slug: what-can-iiif-do
name: What can IIIF do?
- slug: why-use-iiif
name: Why use IIIF?

- slug: image-api
name: Image API
pages:
- slug: playground
name: Playground

- slug: presentation-api
name: Presentation API
12 changes: 12 additions & 0 deletions src/_image-api/playground.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
layout: page
title: Image API Playground
---

{% raw %}

{scheme}://{server}{/prefix}/{identifier}/{region}/{size}/{rotation}/{quality}.{format}

{% endraw %}

<div id='image-api-playground'> </div>
4 changes: 2 additions & 2 deletions src/_overview/what-can-iiif-do.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ As of July 2017 the current IIIF Technical Specifications are:
- [IIIF Authentication API](http://iiif.io/api/auth/1.0)
- [IIIF Search API](http://iiif.io/api/search/1.0)

The two most established IIIF APIs are the Image and Presentation APIs. This guide will discuss these in more depth.
The two most established IIIF APIs are the Image and Presentation APIs. This guide will discuss these in more depth. Let's get started with the Image API.

<div class='d-flex justify-content-around'>
<a class="btn btn-secondary" href="{{'overview/why-use-iiif' | relative_url }}">Next &raquo;</a>
<a class="btn btn-secondary" href="{{'image-api' | relative_url }}">Next &raquo;</a>
</div>
4 changes: 0 additions & 4 deletions src/_overview/why-use-iiif.md

This file was deleted.

4 changes: 4 additions & 0 deletions src/_sass/image_api_playground.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.img-container {
background: $gray;
min-height: 400px;
}
1 change: 1 addition & 0 deletions src/assets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
@import '../../node_modules/bootstrap/scss/bootstrap';

@import 'application';
@import 'image_api_playground';
55 changes: 55 additions & 0 deletions src/assets/spinning-circles.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/image_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
layout: page
title: Image API
permalink: /image-api/
---

The IIIF Image API is designed for standardization of requesting and delivering images on the Web.
116 changes: 116 additions & 0 deletions src/javascripts/components/ImageApiPlayground.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Img from 'react-image';

class ImageApiPlayground extends Component {
constructor(props) {
super(props);

this.state = {
region: '1015,1460,799,824',
size: 'pct:25',
rotation: '0',
quality: 'default',
format: 'jpg',
};

this.handleChange = this.handleChange.bind(this);
this.imageUrl = this.imageUrl.bind(this);
}
imageUrl() {
return `${this.props.urlPrefix}/${this.state.region}/${this.state.size}/${this.state.rotation}/${this.state.quality}.${this.state.format}`
}

handleChange(event) {
const newState = {};
newState[event.target.placeholder] = event.target.value;
this.setState(newState);
}


render() {
const image = this.imageUrl();
const spinner = (<img alt="spinner" className="" src='/assets/spinning-circles.svg'/>);
return (
<div>
<div className="row">
{this.props.urlPrefix}/
</div>
<div className="row">
<div className="col-3">
<input
type="text"
className="form-control"
placeholder="region"
value={this.state.region}
onChange={this.handleChange}

/>
</div>
/
<div className="col-2">
<input
type="text"
className="form-control"
placeholder="size"
value={this.state.size}
onChange={this.handleChange}

/>
</div>
/
<div className="col-2">
<input
type="text"
className="form-control"
placeholder="rotation"
value={this.state.rotation}
onChange={this.handleChange}

/>
</div>
/
<div className="col-2">
<input
type="text"
className="form-control"
placeholder="quality"
value={this.state.quality}
onChange={this.handleChange}

/>
</div>
.
<div className="col-2">
<input
type="text"
className="form-control"
placeholder="format"
value={this.state.format}
onChange={this.handleChange}

/>
</div>
</div>
<div className="row p-4">
<div className="col-md-12 img-container rounded">
<div className="container d-flex h-100 justify-content-center">
<div className="row align-self-center">
<Img src={image} loader={spinner} className="p-4" />
</div>
</div>
</div>
</div>
</div>
);
}
}

// https://stacks.stanford.edu/image/iiif/hg676jb4964%2F0380_796-44/1015,1460,799,824/pct:25/0/default.jpg

ImageApiPlayground.propTypes = {
region: PropTypes.string,
urlPrefix: PropTypes.string,
}

export default ImageApiPlayground;
16 changes: 13 additions & 3 deletions src/javascripts/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
console.log('holla')
import React, { PureComponent } from 'react';
import { render } from 'react-dom';
import ImageApiPlayground from './components/ImageApiPlayground';

class App extends PureComponent {
render() {
return (
<ImageApiPlayground
urlPrefix="https://stacks.stanford.edu/image/iiif/hg676jb4964%2F0380_796-44"
/>
);
}
}

console.log('back')
console.log('nextsdfkldsf')
render(<App />, document.getElementById('image-api-playground'));
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
module: {
loaders: [
{
test: /\.js?$/,
test: /\.jsx?$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
query: {
Expand Down
8 changes: 7 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2555,7 +2555,7 @@ promise@^7.1.1:
dependencies:
asap "~2.0.3"

prop-types@^15.5.10:
prop-types@^15.5.10, prop-types@^15.5.8:
version "15.5.10"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154"
dependencies:
Expand Down Expand Up @@ -2634,6 +2634,12 @@ react-dom@^15.6.1:
object-assign "^4.1.0"
prop-types "^15.5.10"

react-image@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/react-image/-/react-image-1.0.1.tgz#eb3178a7b2a09945310a4bea6f89317d8b6f8c40"
dependencies:
prop-types "^15.5.8"

react@^15.6.1:
version "15.6.1"
resolved "https://registry.yarnpkg.com/react/-/react-15.6.1.tgz#baa8434ec6780bde997cdc380b79cd33b96393df"
Expand Down

0 comments on commit 05adade

Please sign in to comment.