Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generating downloads from JSON #187

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
195 changes: 195 additions & 0 deletions downloads.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be way more useful as a normalized JSON where each item in an array has id. ie. https://github.com/paularmstrong/normalizr

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be more complicated for no benefit. Leaving things like this is good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you need ids for? Isn't it better to access elements by name:
downloads["stable"]["Windows"]["qTox"] instead of downloads["stable"]["0"]["0"] ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it wouldn't be downloads["stable"]["0"]["0"], but my point is that it's more difficult to make a mistake with names and ids are more difficult to remember, because they don't mean anything. I don't understand why it would be more useful with ids. Maybe you could give an example?

"stable":
[
{
"name": "Windows",
"qTox":
[
{
"name": "32 bit",
"url": "https://build.tox.chat/view/qtox/job/qTox_pkg_windows_x86_stable_release/lastSuccessfulBuild/artifact/setup-qtox.exe",
"sha256": "",
"gpg": ""
},

{
"name": "64 bit",
"url": "https://build.tox.chat/view/qtox/job/qTox_pkg_windows_x86-64_stable_release/lastSuccessfulBuild/artifact/setup-qtox.exe",
"sha256": "",
"gpg": ""
}
],
"uTox":
[
{
"name": "32 bit",
"url": "https://downloads.utox.io/stable/uTox_win32.exe",
"sha256": "",
"gpg": ""
},

{
"name": "64 bit",
"url": "https://downloads.utox.io/stable/uTox_win64.exe",
"sha256": "",
"gpg": ""
}
]
},

{
"name": "OS X",
"qTox":
[
{
"name": "32 bit",
"url": "https://github.com/qTox/qTox/releases/download/v1.13.0/qTox.dmg",
"sha256": "",
"gpg": ""
}
],
"uTox":
[
{
"name": "64 bit (OS X 10.7+)",
"url": "https://github.com/uTox/uTox/releases/download/v0.16.1/uTox-0.16.1.dmg",
"sha256": "",
"gpg": ""
}
]
},

{
"name": "GNU/Linux",
"":
[
{
"name": "Debian",
"url": "#gnulinux"
},

{
"name": "Gentoo",
"url": "#gnulinux"
},

{
"name": "Arch",
"url": "#gnulinux"
}
],
"uTox mostly static":
[
{
"name": "32 bit",
"url": "https://build.tox.chat/job/uTox_build_linux_x86_release/lastSuccessfulBuild/artifact/utox_linux_x86.tar.xz"
},
{
"name": "64 bit",
"url": "https://build.tox.chat/job/uTox_build_linux_x86-64_release/lastSuccessfulBuild/artifact/utox_linux_x86-64.tar.xz"
}
],
"Toxic mostly static":
[
{
"name": "32 bit",
"url": "https://build.tox.chat/job/toxic_build_linux_x86_release/lastSuccessfulBuild/artifact/toxic_build_linux_x86_release.tar.xz"
},
{
"name": "64 bit",
"url": "https://build.tox.chat/job/toxic_build_linux_x86-64_release/lastSuccessfulBuild/artifact/toxic_build_linux_x86-64_release.tar.xz"
}
],
"Toxic fully static (text chat only)":
[
{
"name": "32 bit",
"url": "https://build.tox.chat/job/toxic-no-x11-musl_build_linux_x86_release/lastSuccessfulBuild/artifact/toxic-no-x11-musl_build_linux_x86_release.tar.xz"
},
{
"name": "64 bit",
"url": "https://build.tox.chat/job/toxic-no-x11-musl_build_linux_x86-64_release/lastSuccessfulBuild/artifact/toxic-no-x11-musl_build_linux_x86-64_release.tar.xz"
}
]
},

{
"name": "FreeBSD",
"":
[
{
"name": "qTox",
"url": "https://www.freshports.org/net-im/qTox"
},


{
"name": "uTox",
"url": "https://www.freshports.org/net-im/uTox"
},


{
"name": "Toxic",
"url": "https://www.freshports.org/net-im/toxic"
}
]
},

{
"name": "iOS",
"":
[
{
"name": "Antidote (iOS 8+)",
"url": "https://itunes.apple.com/app/antidote-for-tox/id933117605"
}
]
},

{
"name": "Android",
"Antox":
[
{
"name": "F-droid",
"url": "#fdroid"
},

{
"name": "Google-Play",
"url": "https://play.google.com/store/apps/details?id=chat.tox.antox"
},

{
"name": "APK",
"url": "https://pkg.tox.chat/fdroid/repo/antox.apk"
}
]
}
],

"nightly":
[
{
"name": "qTox nightly",
"Windows":
[
{
"name": "32 bit",
"url": "https://build.tox.chat/view/qtox/job/qTox_build_windows_x86_release/lastSuccessfulBuild/artifact/qTox_build_windows_x86_release.zip",
"sha256": "",
"gpg": ""
},

{
"name": "64 bit",
"url": "https://build.tox.chat/view/qtox/job/qTox_build_windows_x86-64_release/lastSuccessfulBuild/artifact/qTox_build_windows_x86-64_release.zip",
"sha256": "",
"gpg": ""
}
]
}
]

}
7 changes: 7 additions & 0 deletions pelicanconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

THEME = "themes/website"

DOWNLOADS_JSON_PATH = "downloads.json"

# pelican is mainly aimed at blogs and a regular pelican template has only
# a predefined set of files with predefined names which do blog things.
Expand All @@ -31,6 +32,12 @@

import fnmatch
import os
import json

jsonFile = open(DOWNLOADS_JSON_PATH)
DOWNLOADS = json.load(jsonFile)
jsonFile.close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the file do not exists? Could we add a try/catch block here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the file doesn't exist it will throw a Python error in the console and stop the site from building:

CRITICAL: IOError: [Errno 2] No such file or directory: u'downloads.json'
Makefile:28: recipe for target 'html' failed
make: *** [html] Error 1

We could have a try catch with our own messages for different kinds of exceptions, but is there an advantage?



TEMPLATES_DIR = THEME + '/templates'
for root, dirnames, filenames in os.walk(TEMPLATES_DIR):
Expand Down
3 changes: 3 additions & 0 deletions themes/website/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,9 @@ input[type=checkbox]:checked ~ #hamlabel:before {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale
}
.icon-distro-small:before {
font-size: 18px;
}
.icon-debian:before{content:"\0041";}
.icon-gentoo:before{content:"\0042";}
.icon-arch:before{content:"\0043";}
Expand Down
Loading