Skip to content

Commit

Permalink
Fix comment (#172)
Browse files Browse the repository at this point in the history
* Add new codings and fix bugs

* Add new codings and fix bugs

* Fix comment system

Co-authored-by: andreytopchiy <[email protected]>
  • Loading branch information
Kanaduchi and AnTopch authored Sep 12, 2022
1 parent c13492d commit 438c785
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 195 deletions.
3 changes: 1 addition & 2 deletions docs/history.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
disqus: ""
giscus: ""
comments: false
---
# История изменений

Expand Down
3 changes: 1 addition & 2 deletions docs/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ title: Coding of VW cars
template: ./main.en.html
hide:
- toc
disqus: ""
giscus: ""
comments: false
---

<style>
Expand Down
3 changes: 1 addition & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
hide:
- toc
disqus: ""
giscus: ""
comments: false
---

<style>
Expand Down
3 changes: 1 addition & 2 deletions docs/main.en.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
template: ./home.en.html
title: Coding of VW cars
disqus: ""
giscus: ""
comments: false
---
3 changes: 1 addition & 2 deletions docs/main.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
template: ./home.html
title: Кодирование автомобилей VAG
disqus: ""
giscus: ""
comments: false
---
1 change: 0 additions & 1 deletion docs/questions.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@

# Обратная связь
Если у вас возникли какие-то вопросы, предложения, пожелания, можете оставить их на этой странице.
17 changes: 10 additions & 7 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,16 @@ extra_css:
- assets/custom.css

extra:
disqus: https-mqb-readthedocs-io
giscus:
enable: false
repo: Kanaduchi/vwcoding
repo_id: MDEwOlJlcG9zaXRvcnkyMTQ4NTE3Njk=
category: General
category_id: MDE4OkRpc2N1c3Npb25DYXRlZ29yeTMyNjYxNjIy
comments:
enable: true
# Can be disqus or giscus
type: disqus
# Url for disqus
disqus_url: https-mqb-readthedocs-io
repo: Kanaduchi/vwcoding
repo_id: MDEwOlJlcG9zaXRvcnkyMTQ4NTE3Njk=
category: General
category_id: MDE4OkRpc2N1c3Npb25DYXRlZ29yeTMyNjYxNjIy
alternate:
- name: Русский
link: ./
Expand Down
88 changes: 0 additions & 88 deletions overrides/main.en.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,92 +36,4 @@
<!-- content block -->
{% block content %}
{{ super() }}

<!-- Inject Disqus into current page -->
{% set disqus = config.extra.disqus %}
{% if page and page.meta and page.meta.disqus is string %}
{% set disqus = page.meta.disqus %}
{% endif %}

{% if not page.is_homepage and disqus %}
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
<div id="disqus_thread"></div>
<script>
var disqus_config = function() {
this.page.url = "{{ page.canonical_url }}"
this.page.identifier =
"{{ page.canonical_url | replace(config.site_url, '') }}"

}

/* Set up for the first time */
if (typeof DISQUS === "undefined") {
var script = document.createElement("script")
script.async = true
script.src = "https://{{ disqus }}.disqus.com/embed.js"
script.setAttribute("data-timestamp", Date.now())

/* Inject script tag */
document.body.appendChild(script)

/* Set up on navigation (instant loading) */
} else {
DISQUS.reset({
reload: true,
config: disqus_config
})
}
</script>
{% endif %}

<!-- Giscus -->
{% set giscus = config.extra.giscus %}
{% if page and page.meta and page.meta.giscus is string %}
{% set giscus = page.meta.giscus %}
{% endif %}
{% if giscus and giscus.enable %}
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
<!-- Replace with generated snippet -->
<script src="https://giscus.app/client.js"
data-repo="{{ giscus.repo }}"
data-repo-id="{{ giscus.repo_id }}"
data-category="{{ giscus.category }}"
data-category-id="{{ giscus.category_id }}"
data-mapping="pathname"
data-reactions-enabled="1"
data-emit-metadata="0"
data-theme="light"
data-lang="{{ language }}"
crossorigin="anonymous"
async>
</script>
{% endif %}

<!-- Reload on palette change -->
<script>
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object")
if (palette.color.scheme === "slate") {
var giscus = document.querySelector("script[src*=giscus]")
giscus.setAttribute("data-theme", "dark")
}

/* Register event handlers after documented loaded */
document.addEventListener("DOMContentLoaded", function() {
var ref = document.querySelector("[data-md-component=palette]")
ref.addEventListener("change", function() {
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object") {
var theme = palette.color.scheme === "slate" ? "dark" : "light"

/* Instruct Giscus to change theme */
var frame = document.querySelector(".giscus-frame")
frame.contentWindow.postMessage(
{ giscus: { setConfig: { theme } } },
"https://giscus.app"
)
}
})
})
</script>
{% endblock %}
88 changes: 0 additions & 88 deletions overrides/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,92 +36,4 @@
<!-- content block -->
{% block content %}
{{ super() }}

<!-- Inject Disqus into current page -->
{% set disqus = config.extra.disqus %}
{% if page and page.meta and page.meta.disqus is string %}
{% set disqus = page.meta.disqus %}
{% endif %}

{% if not page.is_homepage and disqus %}
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
<div id="disqus_thread"></div>
<script>
var disqus_config = function() {
this.page.url = "{{ page.canonical_url }}"
this.page.identifier =
"{{ page.canonical_url | replace(config.site_url, '') }}"

}

/* Set up for the first time */
if (typeof DISQUS === "undefined") {
var script = document.createElement("script")
script.async = true
script.src = "https://{{ disqus }}.disqus.com/embed.js"
script.setAttribute("data-timestamp", Date.now())

/* Inject script tag */
document.body.appendChild(script)

/* Set up on navigation (instant loading) */
} else {
DISQUS.reset({
reload: true,
config: disqus_config
})
}
</script>
{% endif %}

<!-- Giscus -->
{% set giscus = config.extra.giscus %}
{% if page and page.meta and page.meta.giscus is string %}
{% set giscus = page.meta.giscus %}
{% endif %}
{% if giscus and giscus.enable %}
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
<!-- Replace with generated snippet -->
<script src="https://giscus.app/client.js"
data-repo="{{ giscus.repo }}"
data-repo-id="{{ giscus.repo_id }}"
data-category="{{ giscus.category }}"
data-category-id="{{ giscus.category_id }}"
data-mapping="pathname"
data-reactions-enabled="1"
data-emit-metadata="0"
data-theme="light"
data-lang="{{ language }}"
crossorigin="anonymous"
async>
</script>
{% endif %}

<!-- Reload on palette change -->
<script>
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object")
if (palette.color.scheme === "slate") {
var giscus = document.querySelector("script[src*=giscus]")
giscus.setAttribute("data-theme", "dark")
}

/* Register event handlers after documented loaded */
document.addEventListener("DOMContentLoaded", function() {
var ref = document.querySelector("[data-md-component=palette]")
ref.addEventListener("change", function() {
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object") {
var theme = palette.color.scheme === "slate" ? "dark" : "light"

/* Instruct Giscus to change theme */
var frame = document.querySelector(".giscus-frame")
frame.contentWindow.postMessage(
{ giscus: { setConfig: { theme } } },
"https://giscus.app"
)
}
})
})
</script>
{% endblock %}
83 changes: 83 additions & 0 deletions overrides/partials/comments.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<!-- Comments -->
{% set comments = config.extra.comments %}
{% if comments.enable %}
{%if page.meta.comments or page.meta.comments == null %}
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>

{% if comments.type == "disqus" %}
<div id="disqus_thread"></div>
<script>
var disqus_config = function() {
this.page.url = "{{ page.canonical_url }}"
this.page.identifier =
"{{ page.canonical_url | replace(config.site_url, '') }}"
}
/* Set up for the first time */
if (typeof DISQUS === "undefined") {
var script = document.createElement("script")
script.async = true
script.src = "https://{{ comments.disqus_url }}.disqus.com/embed.js"
script.setAttribute("data-timestamp", Date.now())

/* Inject script tag */
document.body.appendChild(script)

/* Set up on navigation (instant loading) */
} else {
DISQUS.reset({
reload: true,
config: disqus_config
})
}
</script>
{% endif %}

{% if comments.type == "giscus" %}
<!-- Insert generated code here -->
<script src="https://giscus.app/client.js"
data-repo="{{ comments.repo }}"
data-repo-id="{{ comments.repo_id }}"
data-category="{{ comments.category }}"
data-category-id="{{ comments.category_id }}"
data-mapping="pathname"
data-reactions-enabled="1"
data-emit-metadata="0"
data-theme="light"
data-lang="{{ config.theme.language }}"
crossorigin="anonymous"
async>
</script>
{% endif %}

<!-- Synchronize Giscus theme with palette -->
<script>
var giscus = document.querySelector("script[src*=giscus]")
{% if giscus %}
/* Set palette on initial load */
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object") {
var theme = palette.color.scheme === "slate" ? "dark" : "light"
giscus.setAttribute("data-theme", theme)
}

/* Register event handlers after documented loaded */
document.addEventListener("DOMContentLoaded", function() {
var ref = document.querySelector("[data-md-component=palette]")
ref.addEventListener("change", function() {
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object") {
var theme = palette.color.scheme === "slate" ? "dark" : "light"

/* Instruct Giscus to change theme */
var frame = document.querySelector(".giscus-frame")
frame.contentWindow.postMessage(
{ giscus: { setConfig: { theme } } },
"https://giscus.app"
)
}
})
})
{% endif %}
</script>
{% endif %}
{% endif %}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mkdocs-material==8.4.0
mkdocs-material==8.4.4
mkdocs-print-site-plugin==2.3.4
mkdocs-static-i18n==0.46

0 comments on commit 438c785

Please sign in to comment.