-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.html
247 lines (237 loc) · 7.92 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>README.md Gallery Creator for GitHub</title>
<meta name="description" content="Add a gallery to your GitHub repository's markdown README.md file that contains screenshots and images of your project." />
<script>
window.onload = function() {
var input = document.getElementById("input");
var adjustor = document.getElementById("adjustor");
var adjustorDisplay = document.getElementById("adjustor-display");
var spacor = document.getElementById("spacor");
var output = document.getElementById("output");
var render = function(ev) {
var text = "";
// we do not base the calculation on 100% with to ensure
// images fit despite borders, paddings or added spaces
// that reduce the available width…
var imagesPerRow = Math.round(90 / parseInt(adjustor.value));
var re = /\[[^\]]+\]\(([^)]+)\)/g;
while(url = re.exec(input.value)) { // assignement, not comparison!
text += '<img'
+ ' src="' + url[1] + '"'
+ ' width="' + imagesPerRow + '%">'
+ '</img>'
+ (spacor.checked ? " " : "");
}
// update the preview
preview.innerHTML = text;
adjustorDisplay.innerHTML = adjustor.value;
// update the code for the readme
output.value = text;
};
input.addEventListener('keyup', render, false);
adjustor.addEventListener('input', render, false);
spacor.addEventListener('change', render, false);
output.addEventListener('click', function() {
this.focus();
this.select();
}, false);
// call render once at startup
render();
};
</script>
<style type="text/css">
*, *:before, *:after {
box-sizing: border-box;
}
html, body {
margin: 0;
padding: 0;
font: 13px/1.4 Helvetica, arial, nimbussansl, liberationsans, freesans, clean, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
color: #333;
margin-bottom: 30px;
}
footer {
position: fixed;
text-align: left;
border-top: 1px solid gray;
background-color: #7D7D7D;
color: white;
bottom: 0px;
left: 0;
right: 0;
padding-top: 5px;
}
footer span {
vertical-align: super;
}
footer a {
color: white;
}
body > .page {
padding: 5px;
}
.page {
max-width: 790px;
margin: auto;
}
header {
text-align: center;
background: white;
}
#intro {
text-align: center;
background-color: #645555;
padding: 20px;
color: white;
margin: 0;
font-size: 1.1em;
}
#adjustor {
width: 90%;
}
#output {
height: 200px;
}
.step:not(.full-stretch) {
float: left;
width: 50%;
}
h3 span {
font-size: 1.5em;
color: #937373;
}
.full-stretch {
clear: both;
}
table {
border-collapse: collapse;
width: 100%;
}
th {
background-color: #EBEBEB;
}
tr > * {
border: 1px solid #D8D8D8;
padding: 5px;
}
#adjustor-display {
display: inline-block;
vertical-align: super;
}
#readme {
margin: 30px 0;
width: 100%;
}
#readme h3 {
background-color: #f5f5f5;
margin: 0;
border: 1px solid #d8d8d8;
border-bottom: 0;
padding: 9px 10px 10px;
font-size: 14px;
line-height: 17px;
display: block;
}
#readme h1 {
margin-top: 0;
text-align: left;
border-bottom: 1px solid #eee;
margin-bottom: 16px;
padding-bottom: 0.3em;
}
#readme article {
background-color: #fff;
border: 1px solid #ddd;
padding: 30px;
word-wrap: break-word;
}
h1 {
font-size: 2.25em;
line-height: 1.2;
font-weight: bold;
line-height: 40px;
}
h2 {
color: red
}
textarea {
width: 100%;
height: 4em;
}
</style>
</head>
<body>
<header>
<h1>README.md Gallery Creator for GitHub</h1>
<p id="intro">Always wanted to prove 'em that you are one of the <u>cool guys</u> at GitHub? Then don't miss the chance! Add a gallery to your project's README.md today. Be a winner.</p>
</header>
<div class="page">
<div class="step">
<h3><span>①</span> Create markdown links at GitHub</h3>
<ol>
<li>Go to your GitHub project repository</li>
<li>Open your issue list and click "New Issue"</li>
<li>Drag'n'drop your images into the issue's textarea</li>
<li>Copy the markdown code from the issue's textarea</li>
</ol>
</div>
<div class="step">
<h3><span>②</span> Paste the code into the textarea below</h3>
<i>Remove the demo code below, then paste your code…</i>
<textarea id="input">
![2015-09-20 17 02 28](https://cloud.githubusercontent.com/assets/4307137/10105283/251b6868-63ae-11e5-9918-b789d9d682ec.png)
![2015-09-20 17 16 58](https://cloud.githubusercontent.com/assets/4307137/10105290/2a183f3a-63ae-11e5-9380-50d9f6d8afd6.png)
![2015-09-20 17 07 53](https://cloud.githubusercontent.com/assets/4307137/10105284/26aa7ad4-63ae-11e5-88b7-bc523a095c9f.png)
![2015-09-20 17 08 37](https://cloud.githubusercontent.com/assets/4307137/10105288/28698fae-63ae-11e5-8ba7-a62360a8e8a7.png)
![2015-09-20 17 02 28](https://cloud.githubusercontent.com/assets/4307137/10105283/251b6868-63ae-11e5-9918-b789d9d682ec.png)
![2015-09-20 17 16 58](https://cloud.githubusercontent.com/assets/4307137/10105290/2a183f3a-63ae-11e5-9380-50d9f6d8afd6.png)
</textarea>
</div>
<div class="step full-stretch">
<h3><span>③</span> Adjust your gallery like a boss.</h3>
<table>
<tr>
<th>Images per Row</th>
<th>Spacing</th>
</tr>
<tr>
<td>
<input id="adjustor" type="range" min="1" max="20" step="1" value="6" />
<span id="adjustor-display"></span>
</td>
<td>
<label>
<input id="spacor" type="checkbox" name="spacor" value="1" checked>Add a space between the images
</label>
</td>
</tr>
</table>
<div id="readme">
<h3>README.md</h3>
<article>
<h1>Your Project</h1>
<p id="preview"></p>
<p>This is a preview of how the gallery will look in your repo's readme. Of course you can add multiple image galleries and separate them with text. Images that have the same aspect ratio will look better than images with different proportions.</p>
</article>
</div>
</div>
<div class="step full-stretch">
<h3><span>④</span> Now grab yer code and get outta here.</h3>
Click into the textarea below to select the code. Then copy'n'paste it into your project's readme.md and you are good!
By the way, you can also paste it into issues, that will work too!
<textarea id="output"></textarea>
</div>
</div>
<footer>
<div class="page">
<iframe src="https://ghbtns.com/github-btn.html?user=felixhayashi&repo=ReadmeGalleryCreatorForGitHub&type=star&count=true" frameborder="0" scrolling="0" width="80px" height="20px"></iframe>
<span>
Created by <a href="https://github.com/felixhayashi">@felixhayashi</a>. Free of any charge. Enjoy :)
</span>
</div>
</footer>
</body>
</html>