Skip to content

Commit

Permalink
Fixed #1: GitHub stars don't work if the repo_url ends with a '/'
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Feb 10, 2016
1 parent d67bfc0 commit ee05f7d
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
mkdocs-material-0.x.x (2016-xx-xx) [in progress]

* Fixed #1: GitHub stars don't work if the repo_url ends with a '/'

mkdocs-material-0.1.0 (2016-02-09)

* Initial release
1 change: 1 addition & 0 deletions material/assets/stylesheets/application-1f184bc3.css

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion material/assets/stylesheets/application-334f02ec.css

This file was deleted.

2 changes: 1 addition & 1 deletion material/assets/stylesheets/application.css

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions material/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,19 @@
<link rel="icon" type="image/x-icon" href="{{ base_url }}/{{ icon }}">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu:400,700">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu+Mono">
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-334f02ec.css">
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-1f184bc3.css">
{% for path in extra_css %}
<link rel="stylesheet" href="{{ path }}">
{% endfor %}
{% block extrahead %}{% endblock %}
</head>
<body>
{% if repo_name == 'GitHub' %}
{% set repo_id = repo_url | replace('https://github.com/', '') %}
{% if repo_id[-1:] == '/' %}
{% set repo_id = repo_id[:-1] %}
{% endif %}
{% endif %}
<div class="backdrop">
<div class="backdrop-paper"></div>
</div>
Expand Down Expand Up @@ -98,7 +104,6 @@ <h1>{{ site_name }}</h1>
</div>
</main>
<script src="{{ base_url }}/assets/javascripts/modernizr-79394028.js"></script>
{% set repo_id = repo_url | replace('https://github.com/', '') %}
<script>
var base_url = '{{ base_url }}';
var repo_id = '{{ repo_id }}';
Expand Down
3 changes: 0 additions & 3 deletions material/drawer.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{% if repo_name == 'GitHub' %}
{% set repo_id = repo_url | replace('https://github.com/', '') %}
{% endif %}
<nav aria-label="navigation">
<a href="{{ repo_url }}" class="project">
<div class="banner">
Expand Down
2 changes: 1 addition & 1 deletion material/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"assets/images/favicon.ico": "assets/images/favicon-e565ddfa.ico",
"assets/javascripts/application.js": "assets/javascripts/application-d84ecdee.js",
"assets/javascripts/modernizr.js": "assets/javascripts/modernizr-79394028.js",
"assets/stylesheets/application.css": "assets/stylesheets/application-334f02ec.css"
"assets/stylesheets/application.css": "assets/stylesheets/application-1f184bc3.css"
}
4 changes: 2 additions & 2 deletions src/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,9 @@ document.addEventListener('DOMContentLoaded', function() {
function(data, xhr) {
var count = data.stargazers_count;
if (count > 10000)
count = (count / 1000).toFixed(0) + "k";
count = (count / 1000).toFixed(0) + 'k';
else if (count > 1000)
count = (count / 1000).toFixed(1) + "k";
count = (count / 1000).toFixed(1) + 'k';

/* Set number of stars */
var stars = document.querySelector('.repo-stars .count');
Expand Down
13 changes: 12 additions & 1 deletion src/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@
</head>
<body>

<!--
Sadly the jinja template engine is not very flexible - it doesn't support
regular expressions out-of-the-box. Since there might be a slash at the
end of the repository name, we just do a string comparison and kill it.
-->
{% if repo_name == 'GitHub' %}
{% set repo_id = repo_url | replace('https://github.com/', '') %}
{% if repo_id[-1:] == '/' %}
{% set repo_id = repo_id[:-1] %}
{% endif %}
{% endif %}

<!-- Backdrop -->
<div class="backdrop">
<div class="backdrop-paper"></div>
Expand Down Expand Up @@ -170,7 +182,6 @@ <h1>{{ site_name }}</h1>
<script src="{{ base_url }}/assets/javascripts/modernizr.js"></script>

<!-- Theme-related and custom javascripts -->
{% set repo_id = repo_url | replace('https://github.com/', '') %}
<script>
var base_url = '{{ base_url }}';
var repo_id = '{{ repo_id }}';
Expand Down
4 changes: 0 additions & 4 deletions src/drawer.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{% if repo_name == 'GitHub' %}
{% set repo_id = repo_url | replace('https://github.com/', '') %}
{% endif %}

<!-- Navigation -->
<nav aria-label="navigation">

Expand Down

0 comments on commit ee05f7d

Please sign in to comment.