Skip to content

Commit e1fd932

Browse files
authored
Merge pull request #212 from honeylogic-io/scrape-github-markdown
feat: scrape markdown from Github README files
2 parents 3a5157b + 9c78bed commit e1fd932

File tree

7 files changed

+2971
-1917
lines changed

7 files changed

+2971
-1917
lines changed

django_wtf/core/github_tasks.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,11 @@ def index_repository_readme(repo_full_name):
119119
raise ex
120120

121121
markdown_text = b64decode(res.json()["content"]).decode("utf-8")
122+
122123
repo = Repository.objects.get(full_name=repo_full_name)
123-
repo.readme_html = markdown.markdown(markdown_text)
124+
repo.readme_html = markdown.markdown(
125+
markdown_text, extensions=["extra", "codehilite"]
126+
)
124127
repo.save()
125128

126129

django_wtf/static/css/pygments.css

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
pre { line-height: 125%; }
2+
td.linenos .normal { color: #6e7681; background-color: #0d1117; padding-left: 5px; padding-right: 5px; }
3+
span.linenos { color: #6e7681; background-color: #0d1117; padding-left: 5px; padding-right: 5px; }
4+
td.linenos .special { color: #e6edf3; background-color: #6e7681; padding-left: 5px; padding-right: 5px; }
5+
span.linenos.special { color: #e6edf3; background-color: #6e7681; padding-left: 5px; padding-right: 5px; }
6+
.codehilite .hll { background-color: #6e7681 }
7+
.codehilite { background: #0d1117; color: #e6edf3 }
8+
.codehilite .c { color: #8b949e; font-style: italic } /* Comment */
9+
.codehilite .err { color: #f85149 } /* Error */
10+
.codehilite .esc { color: #e6edf3 } /* Escape */
11+
.codehilite .g { color: #e6edf3 } /* Generic */
12+
.codehilite .k { color: #ff7b72 } /* Keyword */
13+
.codehilite .l { color: #a5d6ff } /* Literal */
14+
.codehilite .n { color: #e6edf3 } /* Name */
15+
.codehilite .o { color: #ff7b72; font-weight: bold } /* Operator */
16+
.codehilite .x { color: #e6edf3 } /* Other */
17+
.codehilite .p { color: #e6edf3 } /* Punctuation */
18+
.codehilite .ch { color: #8b949e; font-style: italic } /* Comment.Hashbang */
19+
.codehilite .cm { color: #8b949e; font-style: italic } /* Comment.Multiline */
20+
.codehilite .cp { color: #8b949e; font-weight: bold; font-style: italic } /* Comment.Preproc */
21+
.codehilite .cpf { color: #8b949e; font-style: italic } /* Comment.PreprocFile */
22+
.codehilite .c1 { color: #8b949e; font-style: italic } /* Comment.Single */
23+
.codehilite .cs { color: #8b949e; font-weight: bold; font-style: italic } /* Comment.Special */
24+
.codehilite .gd { color: #ffa198; background-color: #490202 } /* Generic.Deleted */
25+
.codehilite .ge { color: #e6edf3; font-style: italic } /* Generic.Emph */
26+
.codehilite .ges { color: #e6edf3; font-weight: bold; font-style: italic } /* Generic.EmphStrong */
27+
.codehilite .gr { color: #ffa198 } /* Generic.Error */
28+
.codehilite .gh { color: #79c0ff; font-weight: bold } /* Generic.Heading */
29+
.codehilite .gi { color: #56d364; background-color: #0f5323 } /* Generic.Inserted */
30+
.codehilite .go { color: #8b949e } /* Generic.Output */
31+
.codehilite .gp { color: #8b949e } /* Generic.Prompt */
32+
.codehilite .gs { color: #e6edf3; font-weight: bold } /* Generic.Strong */
33+
.codehilite .gu { color: #79c0ff } /* Generic.Subheading */
34+
.codehilite .gt { color: #ff7b72 } /* Generic.Traceback */
35+
.codehilite .g-Underline { color: #e6edf3; text-decoration: underline } /* Generic.Underline */
36+
.codehilite .kc { color: #79c0ff } /* Keyword.Constant */
37+
.codehilite .kd { color: #ff7b72 } /* Keyword.Declaration */
38+
.codehilite .kn { color: #ff7b72 } /* Keyword.Namespace */
39+
.codehilite .kp { color: #79c0ff } /* Keyword.Pseudo */
40+
.codehilite .kr { color: #ff7b72 } /* Keyword.Reserved */
41+
.codehilite .kt { color: #ff7b72 } /* Keyword.Type */
42+
.codehilite .ld { color: #79c0ff } /* Literal.Date */
43+
.codehilite .m { color: #a5d6ff } /* Literal.Number */
44+
.codehilite .s { color: #a5d6ff } /* Literal.String */
45+
.codehilite .na { color: #e6edf3 } /* Name.Attribute */
46+
.codehilite .nb { color: #e6edf3 } /* Name.Builtin */
47+
.codehilite .nc { color: #f0883e; font-weight: bold } /* Name.Class */
48+
.codehilite .no { color: #79c0ff; font-weight: bold } /* Name.Constant */
49+
.codehilite .nd { color: #d2a8ff; font-weight: bold } /* Name.Decorator */
50+
.codehilite .ni { color: #ffa657 } /* Name.Entity */
51+
.codehilite .ne { color: #f0883e; font-weight: bold } /* Name.Exception */
52+
.codehilite .nf { color: #d2a8ff; font-weight: bold } /* Name.Function */
53+
.codehilite .nl { color: #79c0ff; font-weight: bold } /* Name.Label */
54+
.codehilite .nn { color: #ff7b72 } /* Name.Namespace */
55+
.codehilite .nx { color: #e6edf3 } /* Name.Other */
56+
.codehilite .py { color: #79c0ff } /* Name.Property */
57+
.codehilite .nt { color: #7ee787 } /* Name.Tag */
58+
.codehilite .nv { color: #79c0ff } /* Name.Variable */
59+
.codehilite .ow { color: #ff7b72; font-weight: bold } /* Operator.Word */
60+
.codehilite .pm { color: #e6edf3 } /* Punctuation.Marker */
61+
.codehilite .w { color: #6e7681 } /* Text.Whitespace */
62+
.codehilite .mb { color: #a5d6ff } /* Literal.Number.Bin */
63+
.codehilite .mf { color: #a5d6ff } /* Literal.Number.Float */
64+
.codehilite .mh { color: #a5d6ff } /* Literal.Number.Hex */
65+
.codehilite .mi { color: #a5d6ff } /* Literal.Number.Integer */
66+
.codehilite .mo { color: #a5d6ff } /* Literal.Number.Oct */
67+
.codehilite .sa { color: #79c0ff } /* Literal.String.Affix */
68+
.codehilite .sb { color: #a5d6ff } /* Literal.String.Backtick */
69+
.codehilite .sc { color: #a5d6ff } /* Literal.String.Char */
70+
.codehilite .dl { color: #79c0ff } /* Literal.String.Delimiter */
71+
.codehilite .sd { color: #a5d6ff } /* Literal.String.Doc */
72+
.codehilite .s2 { color: #a5d6ff } /* Literal.String.Double */
73+
.codehilite .se { color: #79c0ff } /* Literal.String.Escape */
74+
.codehilite .sh { color: #79c0ff } /* Literal.String.Heredoc */
75+
.codehilite .si { color: #a5d6ff } /* Literal.String.Interpol */
76+
.codehilite .sx { color: #a5d6ff } /* Literal.String.Other */
77+
.codehilite .sr { color: #79c0ff } /* Literal.String.Regex */
78+
.codehilite .s1 { color: #a5d6ff } /* Literal.String.Single */
79+
.codehilite .ss { color: #a5d6ff } /* Literal.String.Symbol */
80+
.codehilite .bp { color: #e6edf3 } /* Name.Builtin.Pseudo */
81+
.codehilite .fm { color: #d2a8ff; font-weight: bold } /* Name.Function.Magic */
82+
.codehilite .vc { color: #79c0ff } /* Name.Variable.Class */
83+
.codehilite .vg { color: #79c0ff } /* Name.Variable.Global */
84+
.codehilite .vi { color: #79c0ff } /* Name.Variable.Instance */
85+
.codehilite .vm { color: #79c0ff } /* Name.Variable.Magic */
86+
.codehilite .il { color: #a5d6ff } /* Literal.Number.Integer.Long */

django_wtf/templates/core/repository_detail.html

Lines changed: 81 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
{% extends "core/base.html" %}
2+
{% load static %}
3+
{% block head %}
4+
{{ block.super }}
5+
<link rel="stylesheet"
6+
type="text/css"
7+
href="{% static 'css/pygments.css' %}" />
8+
{% endblock head %}
9+
210
{% block content %}
311
<div class="flex-col content-center self-center w-full mb-5 lg:mt-5 lg:flex lg:w-7/12">
412
<div class="flex mt-10 mb-10">
@@ -8,77 +16,83 @@
816
<div class="my-3">
917
{% for topic in object.topics %}<div class="ml-1 badge badge-outline">{{ topic }}</div>{% endfor %}
1018
</div>
19+
<div class="divider"></div>
20+
<div>
21+
<article class="prose">{{ object.readme_html | safe }}</article>
22+
</div>
1123
</div>
12-
<div class="ml-6 shadow stats stats-vertical">
13-
<div class="stat">
14-
<div class="stat-figure text-info">
15-
<svg xmlns="http://www.w3.org/2000/svg"
16-
class="icon icon-tabler icon-tabler-star"
17-
width="24"
18-
height="24"
19-
viewBox="0 0 24 24"
20-
stroke-width="1.5"
21-
stroke="currentColor"
22-
fill="none"
23-
stroke-linecap="round"
24-
stroke-linejoin="round">
25-
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
26-
<path d="M12 17.75l-6.172 3.245l1.179 -6.873l-5 -4.867l6.9 -1l3.086 -6.253l3.086 6.253l6.9 1l-5 4.867l1.179 6.873z" />
27-
</svg>
24+
<div>
25+
<div class="ml-6 stats stats-vertical">
26+
<div class="stat">
27+
<div class="stat-figure text-info">
28+
<svg xmlns="http://www.w3.org/2000/svg"
29+
class="icon icon-tabler icon-tabler-star"
30+
width="24"
31+
height="24"
32+
viewBox="0 0 24 24"
33+
stroke-width="1.5"
34+
stroke="currentColor"
35+
fill="none"
36+
stroke-linecap="round"
37+
stroke-linejoin="round">
38+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
39+
<path d="M12 17.75l-6.172 3.245l1.179 -6.873l-5 -4.867l6.9 -1l3.086 -6.253l3.086 6.253l6.9 1l-5 4.867l1.179 6.873z" />
40+
</svg>
41+
</div>
42+
<div class="stat-title">Stars</div>
43+
<div class="stat-value text-info">{{ object.stars }}</div>
44+
<div class="stat-desc">{{ stars_increase_monthly_percent | floatformat:2 }}% more than last month</div>
2845
</div>
29-
<div class="stat-title">Stars</div>
30-
<div class="stat-value text-info">{{ object.stars }}</div>
31-
<div class="stat-desc">{{ stars_increase_monthly_percent | floatformat:2 }}% more than last month</div>
32-
</div>
33-
<div class="stat">
34-
<div class="stat-figure text-primary">
35-
<svg xmlns="http://www.w3.org/2000/svg"
36-
class="icon icon-tabler icon-tabler-git-fork"
37-
width="24"
38-
height="24"
39-
viewBox="0 0 24 24"
40-
stroke-width="1.5"
41-
stroke="currentColor"
42-
fill="none"
43-
stroke-linecap="round"
44-
stroke-linejoin="round">
45-
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
46-
<path d="M12 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" />
47-
<path d="M7 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" />
48-
<path d="M17 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" />
49-
<path d="M7 8v2a2 2 0 0 0 2 2h6a2 2 0 0 0 2 -2v-2" />
50-
<path d="M12 12l0 4" />
51-
</svg>
46+
<div class="stat">
47+
<div class="stat-figure text-primary">
48+
<svg xmlns="http://www.w3.org/2000/svg"
49+
class="icon icon-tabler icon-tabler-git-fork"
50+
width="24"
51+
height="24"
52+
viewBox="0 0 24 24"
53+
stroke-width="1.5"
54+
stroke="currentColor"
55+
fill="none"
56+
stroke-linecap="round"
57+
stroke-linejoin="round">
58+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
59+
<path d="M12 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" />
60+
<path d="M7 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" />
61+
<path d="M17 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" />
62+
<path d="M7 8v2a2 2 0 0 0 2 2h6a2 2 0 0 0 2 -2v-2" />
63+
<path d="M12 12l0 4" />
64+
</svg>
65+
</div>
66+
<div class="stat-title">Forks</div>
67+
<div class="stat-value text-primary">{{ object.forks }}</div>
5268
</div>
53-
<div class="stat-title">Forks</div>
54-
<div class="stat-value text-primary">{{ object.forks }}</div>
55-
</div>
56-
<div class="stat">
57-
<div class="stat-figure text-error">
58-
<svg xmlns="http://www.w3.org/2000/svg"
59-
class="icon icon-tabler icon-tabler-bug"
60-
width="24"
61-
height="24"
62-
viewBox="0 0 24 24"
63-
stroke-width="1.5"
64-
stroke="currentColor"
65-
fill="none"
66-
stroke-linecap="round"
67-
stroke-linejoin="round">
68-
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
69-
<path d="M9 9v-1a3 3 0 0 1 6 0v1" />
70-
<path d="M8 9h8a6 6 0 0 1 1 3v3a5 5 0 0 1 -10 0v-3a6 6 0 0 1 1 -3" />
71-
<path d="M3 13l4 0" />
72-
<path d="M17 13l4 0" />
73-
<path d="M12 20l0 -6" />
74-
<path d="M4 19l3.35 -2" />
75-
<path d="M20 19l-3.35 -2" />
76-
<path d="M4 7l3.75 2.4" />
77-
<path d="M20 7l-3.75 2.4" />
78-
</svg>
69+
<div class="stat">
70+
<div class="stat-figure text-error">
71+
<svg xmlns="http://www.w3.org/2000/svg"
72+
class="icon icon-tabler icon-tabler-bug"
73+
width="24"
74+
height="24"
75+
viewBox="0 0 24 24"
76+
stroke-width="1.5"
77+
stroke="currentColor"
78+
fill="none"
79+
stroke-linecap="round"
80+
stroke-linejoin="round">
81+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
82+
<path d="M9 9v-1a3 3 0 0 1 6 0v1" />
83+
<path d="M8 9h8a6 6 0 0 1 1 3v3a5 5 0 0 1 -10 0v-3a6 6 0 0 1 1 -3" />
84+
<path d="M3 13l4 0" />
85+
<path d="M17 13l4 0" />
86+
<path d="M12 20l0 -6" />
87+
<path d="M4 19l3.35 -2" />
88+
<path d="M20 19l-3.35 -2" />
89+
<path d="M4 7l3.75 2.4" />
90+
<path d="M20 7l-3.75 2.4" />
91+
</svg>
92+
</div>
93+
<div class="stat-title">Open Issues</div>
94+
<div class="stat-value text-error">{{ object.open_issues }}</div>
7995
</div>
80-
<div class="stat-title">Open Issues</div>
81-
<div class="stat-value text-error">{{ object.open_issues }}</div>
8296
</div>
8397
</div>
8498
</div>

0 commit comments

Comments
 (0)