Skip to content

Commit

Permalink
feat(index.html):added download links (osx,ubuntu)
Browse files Browse the repository at this point in the history
All assets are configured via shared.yaml and are located elsewhere in
the web. This could lead to broken assets at some point, but I am just
risking it for know, knowing that it's easily done to have local
resources.

Closes #106
[skip ci]
  • Loading branch information
Byron committed May 10, 2015
1 parent 0e6605d commit 52027c6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions etc/api/shared.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ make:
- api
- cli
html_index:
download_base_url: http://dl.byronimo.de
asset_urls:
crates_img: https://raw.githubusercontent.com/rust-lang/crates.io/master/public/favicon.ico
ubuntu_img: http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png
osx_img: http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74
directories:
# directory under which all generated sources should reside
output: gen
Expand Down
8 changes: 6 additions & 2 deletions src/mako/index.html.mako
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%
import os
import yaml
from util import (gen_crate_dir, api_index, crates_io_url)
from util import (gen_crate_dir, api_index, crates_io_url, program_name)
title = 'Google Service Documentation for Rust'
Expand Down Expand Up @@ -70,9 +70,13 @@ DO NOT EDIT !
<a class="mod" href="${api_index(DOC_ROOT, an, v, ad.make)}" title="${ad.make.id.upper()} docs for the ${an} ${v}">${ad.make.id.upper()}</a>
% if api_name == 'api':
<a href="${crates_io_url(an, v)}"><img src="${html_index.asset_urls.crates_img}" title="This API on crates.io" height="16" width="16"/></a>
% else:
% for os_name in ('ubuntu', 'osx'):
<a href="${html_index.download_base_url + '/google.rs/%s/%s/%s/%s' % (api_name, ad.cargo.build_version, os_name, program_name(an, v))}"><img src="${html_index.asset_urls.get('%s_img' % os_name)}" title="Download the 64bit program" height="16" width="16"/></a>
% endfor ## each os
% endif
% if not loop.last:
,
,
% endif
% endfor # each program type
)</span><br/>
Expand Down
2 changes: 1 addition & 1 deletion src/mako/lib/util.mako
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ ${canonicalName}\
</%def>

<%def name="program_name()" buffered="True">\
${self.library_name().replace('_', '-')}\
${util.program_name(name, version)}\
</%def>
3 changes: 3 additions & 0 deletions src/mako/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,9 @@ def gen_crate_dir(name, version, ti):
def crates_io_url(name, version):
return "https://crates.io/crates/%s" % library_to_crate_name(library_name(name, version))

def program_name(name, version):
return library_name(name, version).replace('_', '-')

def api_index(DOC_ROOT, name, version, ti, check_exists=True):
crate_dir = gen_crate_dir(name, version, ti)
if ti.documentation_engine == 'rustdoc':
Expand Down

0 comments on commit 52027c6

Please sign in to comment.