Skip to content

Commit

Permalink
allow to serve also from other sources
Browse files Browse the repository at this point in the history
  • Loading branch information
bast committed Oct 19, 2018
1 parent 80c2b54 commit 26d7c4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cicero/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def render_url_markdown(path, engine, engine_version):
md_file_path = '/'.join(_md_file_path)
md_file_path_root = '/'.join(_md_file_path[:-1])
md_file = _md_file_path[-1]
md_file_prefix, _ = os.path.splitext(md_file)

if service == 'github.com':
# we need to translate the reference to a sha (the reference can be a sha)
Expand All @@ -58,8 +57,15 @@ def render_url_markdown(path, engine, engine_version):
root = '{0}/{1}@{2}'.format(owner, repo, sha)

url_prefix = 'https://cdn.jsdelivr.net/gh/{0}/'.format(root)
else:
elif service == 'gitlab.com':
url_prefix = 'https://{0}/{1}/{2}/raw/{3}/'.format(service, owner, repo, ref)
else:
*_url_prefix, md_file = path.split('/')
url_prefix = 'https://' + '/'.join(_url_prefix)
md_file_path = md_file
md_file_path_root = ''

md_file_prefix, _ = os.path.splitext(md_file)

if '/' in md_file_path:
url_prefix += md_file_path_root
Expand Down
1 change: 1 addition & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Examples:

- GitHub: https://cicero.xyz/v3/remark/0.14.0/github.com/bast/cicero/master/demo/talk.md/
- GitLab: https://cicero.xyz/v3/remark/0.14.0/gitlab.com/bast/cicero-example/master/demo/talk.md/
- Some other place: https://cicero.xyz/v3/remark/0.14.0/notabug.org/bast/cicero-example/raw/master/simple-example.md


v2
Expand Down

0 comments on commit 26d7c4c

Please sign in to comment.