Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit adb5c57

Browse files
committed
second commit
1 parent aac94e9 commit adb5c57

File tree

7 files changed

+82
-1
lines changed

7 files changed

+82
-1
lines changed

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/

‎.travis.yml‎

Whitespace-only changes.

‎README.md‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1-
# sketch2code-cli
1+
# sketch2code-cli
2+
3+
# Usage
4+
```bash
5+
curl s2c.sh | bash -s sample.jpg
6+
```
7+
it will generate to sample.html
8+
9+
# Install
10+
```bash
11+
alias s2c.sh='curl s2c.sh | bash -s'
12+
s2c.sh sample.jpg
13+
```
14+
15+
# Uninstall
16+
```bash
17+
unalias s2c.sh
18+
```

‎index.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s2c.sh

‎s2c.sh‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
#<style>html{display:none}</style><script>location='https://github.com/GitHub30/s2c.sh'</script>
3+
4+
sketch=1ドル
5+
6+
if [ ! "$sketch" ]
7+
then
8+
cat << EOS
9+
Usage:
10+
curl s2c.sh | bash -s sample.jpg
11+
it will generate to sample.html
12+
13+
alias s2c.sh='curl s2c.sh | bash -s'
14+
s2c.sh sample.jpg
15+
EOS
16+
exit 1
17+
fi
18+
19+
20+
if [[ $(file -b "$sketch") != 'PNG '* ]]
21+
then
22+
echo "Convert image to PNG"
23+
converted_sketch="${sketch%.*}.png"
24+
convert "$sketch" "$converted_sketch"
25+
sketch="$converted_sketch"
26+
fi
27+
base64 -w0 "$sketch" > /tmp/s2c-base64encoded
28+
29+
30+
cookie='/tmp/s2c-cookie'
31+
# TODO: sketch2code.azurewebsites.net return 503 sometimes. so i use explicit cookie. i have to fix it.
32+
echo 'Retrieve cookie'
33+
curl -sc "$cookie" -H 'Cookie: ARRAffinity=47da2f142b277ae8b362f740e8c2352ecbcbd99358092206caabb5fc38f6e846; ai_user=ni+ui|2018年09月01日T21:00:45.826Z; ai_session=XBt/F|1535835646130|1535835646130' -o /dev/null https://sketch2code.azurewebsites.net/
34+
test -t "$cookie" || cookie='ARRAffinity=47da2f142b277ae8b362f740e8c2352ecbcbd99358092206caabb5fc38f6e846; ai_user=ni+ui|2018年09月01日T21:00:45.826Z; ai_session=XBt/F|1535835646130|1535835646130'
35+
echo 'SaveOriginalFile'
36+
folder_id=$(curl -sb "$cookie" https://sketch2code.azurewebsites.net/SaveOriginalFile --data-urlencode imgBase64@/tmp/s2c-base64encoded | jq -r .folderId)
37+
echo 'upload'
38+
generated_html=$(curl -sb "$cookie" https://sketch2code.azurewebsites.net/upload --data "correlationId=$folder_id" | jq -r .generatedHtml)
39+
40+
cat << EOS > "${1%.*}.html"
41+
<!doctype html>
42+
<html lang="en">
43+
<head>
44+
<meta name="viewport" content="width=device-width" />
45+
<title>HTML Result</title>
46+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css"
47+
integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
48+
</head>
49+
<body>
50+
<div class="container body-content">
51+
${generated_html}
52+
</div>
53+
</body>
54+
</html>
55+
EOS

‎samples/sample1.jpg‎

91.5 KB
Loading[フレーム]

‎test.sh‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
set -xe
3+
4+
bash s2c.sh samples/sample1.jpg
5+
ls samples/
6+
7+
set +xe

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /