-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
145 lines (135 loc) · 4.99 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<html>
<head>
<!--
Use this for development
-->
<!-- <script src="https://unpkg.com/vue"></script>-->
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="https://unpkg.com/vue-rokka-image-lazy@0.4"></script>
<script src="https://unpkg.com/rokka@2.0.1/dist/index.umd.min.js"></script>
<!-- for the gallery part -->
<script type="text/javascript" src="https://unpkg.com/blueimp-gallery@2.27.0/js/blueimp-helper.js"></script>
<script type="text/javascript" src="https://unpkg.com/blueimp-gallery@2.27.0/js/blueimp-gallery.js"></script>
<script type="text/javascript"
src="https://unpkg.com/blueimp-gallery@2.27.0/js/blueimp-gallery-fullscreen.js"></script>
<script type="text/javascript" src="https://unpkg.com/vue-gallery@2.0.1/dist/js/vue-gallery.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
font-size: 12px;
background-color: #f7f7f5;
}
a:link, a:visited {
color: black;
}
.photos {
display: grid;
grid-template-columns: repeat(auto-fill, 200px);
grid-gap: 6px;
text-align: center;
}
.photos > div {
min-height: 230px;
grid-template-rows: 1fr auto;
display: grid;
justify-content: center;
align-items: center;
text-align: center;
background-color: white;
padding: 5px 0;
}
.photos > div > div {
margin-left: auto;
margin-right: auto;
cursor: pointer;
}
.photos .credits {
min-height: 30px;
padding: 0 5px;
}
</style>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/blueimp-gallery@2.27.0/css/blueimp-gallery.min.css">
</head>
<body>
<div id="app">
<gallery :images="galleryImages"
:options="{fullScreen: fullscreen, startSlideshow: slideshow, slideshowInterval: 3000}"
:index="galleryIndex" @close="galleryIndex = null"></gallery>
<h1>vue-rokka-image-lazy, rokka.js, vue-gallery demo</h1>
<div>
Click on an image for gallery view mode.<br/>
<input id="slideshow" type="checkbox" v-model="slideshow" value="false"><label for="slideshow">As automatic
slideshow</label> <br/>
<input id="fullscreen" type="checkbox" v-model="fullscreen" value="false"><label for="fullscreen">In
Fullscreen</label>
</div>
<div class="photos">
<div v-for="(image, index) in images">
<div @click="galleryIndex = index">
<rokka-img
:sourceimage="image"
loading="https://rokka.io/gallery/assets/loader.svg"
:operations="[{name: 'resize', options: {width: 180, height: 180}}]"
:options="[{autoformat: 1}, {autoformat: 1, dpr: 2}]" :postfix="['1x', '2x']">
</rokka-img>
</div>
<div class="credits" v-if="image.user_metadata && image.user_metadata.unsplash_artist_id">
Photo by <a :href="`https://unsplash.com/@${image.user_metadata.unsplash_artist_id}`">{{image.static_metadata.exif.artist}}</a><br/>
on <a :href="`https://unsplash.com/photos/${image.user_metadata.unsplash_photo_id}`">Unsplash</a>
</div>
</div>
</div>
</div>
<script>
const rokkaKey = '1V5HdgIYdFnVu8qU7HfXYiHjVdRtYWFB' //read only key
const rokkaOrg = 'gallery-demo'
const rokkaClient = rokka({
apiKey: rokkaKey,
})
new Vue({
el: '#app',
components: {
RokkaImg: vueRokkaImageLazy.RokkaImgLazy,
'gallery': VueGallery
},
data: {
galleryIndex: null,
slideshow: false,
fullscreen: false,
images: []
},
computed: {
galleryImages() {
return this.images.map(image => {
const url = vueRokkaImageLazy.rokkaUrl(
{
sourceimage: image,
operations: [{name: 'resize', options: {width: 1500, height: 1000}}],
options: {autoformat: 1}
})
return {
href: url,
title: (image.static_metadata && image.static_metadata.exif && image.static_metadata.exif.title) || image.filename
}
}
)
}
},
created() {
// if you don't want to publish your API key or actual search query to the backend
// or want to filter out response data (like some image data fields). You could do a "middleware"
// filter somewhere. Eg. with AWS API Gateway and Lambda. Blogpost will come
/*
fetch('https://9iv7ht2xcd.execute-api.eu-central-1.amazonaws.com/test/gallerydemo').then(resp => {
resp.json().then(body => {
this.images = body.items
})
})*/
rokkaClient.sourceimages.list(rokkaOrg, {limit: 100}).then(result => {
this.images = result.body.items
})
}
})
</script>
</body>
</html>