Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,25 @@ See example page on -

### Usage
It's extremely simple:
1. In ``press.html``, find the ``projectDetails`` object (see example below). using your favorite text editor.
There are 2 ways to use PressKit.js
The first way is to edit data.json.
1. Open data.json. object (see example below). using your favorite text editor.
2. Replace the placeholders with text about your project and with URLs to media files.
3. Add a link to ``press.html`` on your project home page.
3. Validate data.json with https://jsonlint.com/
If you get any erros, you need to edit data.json again.

The other way is to use excel file.
1. Open template.xlsx
2. Add items to the first sheet.
3. Generate data.json with python script.

```bash
$ cd your presskit folder
$ python e2j.py
```


### Sample
```javascript
var projectDetails = {

Expand Down
76 changes: 76 additions & 0 deletions data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"about": [
"paragraph 01",
"paragraph 02"
],
"creators": [
{
"email": "a@b.com",
"name": "name",
"portfolio": "http://example.com",
"twitter": "https://www.twitter.com/name"
},
{
"email": "a@b.com",
"name": "name",
"portfolio": "http://example.com",
"twitter": "https://www.twitter.com/name"
}
],
"footer": [
{
"footerLink": "https://github.com/dodiku/PressKit.js",
"footerText": "PressKit.js"
}
],
"gifs": [
{
"gifUrl": "http://www.url.com"
},
{
"gifUrl": "http://www.url.com"
},
{
"gifUrl": "http://www.url.com"
},
{
"gifUrl": "http://www.url.com"
}
],
"link": "https://google.com",
"photos": [
{
"photoUrl": "http://www.url.com"
},
{
"photoUrl": "http://www.url.com"
},
{
"photoUrl": "http://www.url.com"
}
],
"subtitle": "project subtitle",
"title": "project name",
"videos": [
{
"embedUrl": "http://www.url.com",
"videoPage": "http://www.url.com"
},
{
"embedUrl": "http://www.url.com",
"videoPage": "http://www.url.com"
},
{
"embedUrl": "http://www.url.com",
"videoPage": "http://www.url.com"
},
{
"embedUrl": "http://www.url.com",
"videoPage": "http://www.url.com"
},
{
"embedUrl": "http://www.url.com",
"videoPage": "http://www.url.com"
}
]
}
125 changes: 125 additions & 0 deletions e2j.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import json
import openpyxl


def main():
print('start program')

filename = './template.xlsx'
book = openpyxl.load_workbook(filename)

# get the first sheet
sheet = book.worksheets[0]
data = {}

creators = []
videos = []
gifs = []
photos = []

# parse excel file and generate a json
for row in sheet.rows:
colname = row[0].value
if colname == "title":
title = row[1].value
data.update({"title": title})

elif colname == "subtitle":
subtitle = row[1].value
data.update({"subtitle": subtitle})

elif colname == "link":
link = row[1].value
data.update({"link": link})

elif colname == "creators":
name = row[1].value
portfolio = row[2].value
email = row[3].value
twitter = row[4].value
tmp = {
'name': name,
'portfolio': portfolio,
'email': email,
'twitter': twitter
}
creators.append(tmp)

elif colname == "about":
para1 = row[1].value
para2 = row[2].value

data.update({
'about': [
para1,
para2
]
})

elif colname == "videos":
embed = row[1].value
page = row[2].value
tmp = {
'embedUrl': embed,
'videoPage': page
}
videos.append(tmp)

elif colname == "gifs":
url = row[1].value
tmp = {
"gifUrl": url
}
gifs.append(tmp)

elif colname == "photos":
url = row[1].value
tmp = {
"photoUrl": url
}
photos.append(tmp)

elif colname == "footer":
text = row[1].value
link = row[2].value
data.update({
'footer': [
{
'footerText': text,
'footerLink': link
}
]
})

else:
print("you may put a wrong item in your sheet. Please check your sheet")

data.update({
"creators":
creators
})

data.update({
'videos':
videos
})

data.update({
'gifs':
gifs
})

data.update({
'photos':
photos
})

# generate json
f = open("data.json", "w")
json.dump(data, f, ensure_ascii=False, indent=4,
sort_keys=True, separators=(',', ': '))
print('generated data.json')


if __name__ == '__main__':
main()
97 changes: 7 additions & 90 deletions press.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,98 +2,15 @@
<html lang="en" dir="ltr">

<head>
<title>PRESS KIT</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="presskit_styles.css" />
<link rel="icon" type="image/png" href="favicon.png">
<title>PRESS KIT</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="presskit_styles.css" />
<link rel="icon" type="image/png" href="favicon.png">
</head>

<body>

<script type="text/javascript">
var projectDetails = {

'title': 'project name', // the title of the project

'subTitle': 'project subtitle', // the subtitle of the project

'link': 'http://www.url.com', // link to the project landig page

'creators': [ // supports multiple creators. just add more objects to the array

{
'name': 'name',
'portfolio': 'http://www.url.com',
'email': 'a@b.com',
'twitter': 'http://www.twitter.com/name'
},

{
'name': 'name',
'portfolio': 'http://www.url.com',
'email': 'a@b.com',
'twitter': 'http://www.twitter.com/name'
},

],

'about': [

'paragraph 01',

'paragraph 02',
],

'videos': [ // supports multiple videos. just add more objects to the array

{
'embedUrl': 'http://www.url.com', // e.g. https://www.youtube.com/embed/GjYENsrLLf4
'videoPage': 'http://www.url.com' // e.g. https://www.youtube.com/watch?v=GjYENsrLLf4
},

{
'embedUrl': 'http://www.url.com', // e.g. https://www.youtube.com/embed/GjYENsrLLf4
'videoPage': 'http://www.url.com' // e.g. https://www.youtube.com/watch?v=GjYENsrLLf4
},

],

'gifs': [ // supports multiple gifs. just add more objects to the array

{
'gifUrl': 'http://www.url.com'
},

{
'gifUrl': 'http://www.url.com'
},

],

'photos': [ // supports multiple photos. just add more objects to the array

{
'photoUrl': 'http://www.url.com'
},

{
'photoUrl': 'http://www.url.com'
},

],

'footer': [{
'footerText': "PressKit.js",
'footerLink': "https://github.com/dodiku/PressKit.js"
}, ],

}
</script>


<script type="text/javascript" src="presskit.js"></script>

<script type="text/javascript" src="presskit.js"></script>
</body>

</html>
</html>
Loading