Skip to content

Commit

Permalink
add build deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
陈彦霏 authored and 陈彦霏 committed Nov 6, 2019
1 parent 6e367ee commit 339956d
Show file tree
Hide file tree
Showing 24 changed files with 204 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
*.swp
.vscode/
4 changes: 3 additions & 1 deletion docs/zh_CN/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
_build
_build/
opt/
var/
Binary file added docs/zh_CN/_static/golang-core-course.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/zh_CN/_static/linux-performance-course.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/zh_CN/_static/web-front-end-course.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/zh_CN/_static/zedhz-course.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion docs/zh_CN/_templates/baidu_tongji.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{% set baidu_analytics_id='b4bbaad5115a9e81fb0457a904c870e9' %}

<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?b4bbaad5115a9e81fb0457a904c870e9";
hm.src = "https://hm.baidu.com/hm.js?{{ baidu_analytics_id }}";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
Expand Down
14 changes: 14 additions & 0 deletions docs/zh_CN/_templates/baidu_ziyuan.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script>
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script>
40 changes: 40 additions & 0 deletions docs/zh_CN/_templates/course-ad2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<div id="course-ad2">
<h3>大牛课程</h3>

{% for course in [
{
"url": "https://time.geekbang.org/column/intro/140?code=watzFY59C5wIYB3ECn%2FScBaIFq5k8pPz9UU8ADR%2Fd4s%3D&utm_term=SPoster",
"url": "https://time.geekbang.org/column/intro/140?code=watzFY59C5wIYB3ECn%2FScBaIFq5k8pPz9UU8ADR%2Fd4s%3D",
"path": "_static/linux-performance-course.jpg",
},
{
"url": "https://time.geekbang.org/column/intro/112?code=S1Gimo52SvlZRR-d1JmFhwo3qiM%2FeyKiszh4wwpkW70%3D&utm_term=SPoster",
"url": "https://time.geekbang.org/column/intro/112?code=S1Gimo52SvlZRR-d1JmFhwo3qiM%2FeyKiszh4wwpkW70%3D",
"path": "_static/golang-core-course.jpg",
},
{
"url": "https://time.geekbang.org/column/intro/154?code=VicNYaXq1%2Ff9xQ-rrWlMfr%2FPoyYAw4D8eN8mB5SZTjA%3D&utm_term=SPoster",
"url": "https://time.geekbang.org/column/intro/154?code=VicNYaXq1%2Ff9xQ-rrWlMfr%2FPoyYAw4D8eN8mB5SZTjA%3D",
"path": "_static/web-front-end-course.jpg",
},
{
"url": "https://time.geekbang.org/column/intro/48?code=vPMg2o7CvYAvCtdAV7DY5UvvS1DzcRNcImRZy3KzttE%3D&utm_term=SPoster",
"url": "https://time.geekbang.org/column/intro/48?code=vPMg2o7CvYAvCtdAV7DY5UvvS1DzcRNcImRZy3KzttE%3D",
"path": "_static/zedhz-course.jpg",
},
] %}
<a href="{{ course.url }}">
<img src="{{ pathto(course.path, 1) }}" />
</a>
{% endfor %}

</div>

<style>
#course-ad2 img:hover {
margin-left: 5px;
}
#course-ad2 a {
text-decoration: none;
}
</style>
23 changes: 23 additions & 0 deletions docs/zh_CN/_templates/disqus.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% set disqus_domain='nodejs-book.disqus.com' %}

<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
/*
*/

var disqus_config = function () {
this.page.url = window.location.href; // PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = window.location.pathname; // PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};

(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://{{ disqus_domain }}/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>

<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
4 changes: 4 additions & 0 deletions docs/zh_CN/_templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
<div style="display: none">
<img src="{{ pathto('_static/' ~ theme_logo, 1) }}" />
</div>

{{ super() }}
{% endblock %}

{% block footer %}
{{ super() }}

{% include 'baidu_tongji.html' %}
{% include 'baidu_ziyuan.html' %}
{% include 'disqus.html' %}
{% endblock %}

{#
Expand Down
10 changes: 7 additions & 3 deletions docs/zh_CN/_templates/more.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ <h3>更多阅读</h3>
{% for link in [
{
"title": "Go语言小册",
"url": "https://golang-book.readthedocs.io/zh_CN/latest/",
"url": "https://golang.fasionchan.com/zh_CN/latest/index.html",
},
{
"title": "学习Linux",
"url": "https://linux.fasionchan.com/zh_CN/latest/index.html",
},
{
"title": "Linux网络编程",
"url": "https://linux-network-programming.readthedocs.io/zh_CN/latest/",
"url": "https://network.fasionchan.com/zh_CN/latest/index.html",
},
{
"title": "Python语言小册",
"url": "https://python-book.readthedocs.io/zh_CN/latest/",
"url": "https://python.fasionchan.com/zh_CN/latest/index.html",
},
] %}
<li class="toctree-l1"><a class="reference internal" href="{{ link.url }}">{{ link.title }}</a ></li>
Expand Down
2 changes: 1 addition & 1 deletion docs/zh_CN/about/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
====

.. toctree::
:maxdepth: 2
:titlesonly:

交流 <contact>

Expand Down
13 changes: 11 additions & 2 deletions docs/zh_CN/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import datetime
# import os
import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))

now = datetime.datetime.now()

# -- Project information -----------------------------------------------------

project = u'NodeJs小册'
copyright = u'2018, <a href="#">yan</a>'
author = u'yan'
site_domain = os.environ.get('SITE_DOMAIN', 'nodejs.fasionchan.com')

# The short X.Y version
version = u'1.0'
Expand All @@ -40,6 +42,9 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
"sphinx.ext.mathjax",
"sphinx_sitemap",
]

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -64,7 +69,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = [u'_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = [u'_build', 'Thumbs.db', '.DS_Store', '_fragments', 'opt']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
Expand All @@ -87,6 +92,7 @@
'logo': 'logo.jpg',
#'logo_name': True,
'description': u'简明NodeJs小册子,涵盖基础语法、代码风格以及最佳实践。',
'canonical_url': ('https://' + site_domain + '/zh_CN/latest/'),

'font_family': ','.join(map(repr, [
'Arial',
Expand Down Expand Up @@ -128,6 +134,7 @@
'navigation.html',
'more.html',
'wechat-mp-qrcode.html',
'course-ad2.html',
#'donate.html',

#'reward.html',
Expand Down Expand Up @@ -193,6 +200,8 @@
'Miscellaneous'),
]

site_url = 'https://%s/zh_CN/latest/' % (site_domain,)

def setup(app):
app.add_stylesheet('css/hide-ad.css')
app.add_stylesheet('css/search-box.css')
2 changes: 1 addition & 1 deletion docs/zh_CN/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ NodeJs小册
==========

.. toctree::
:maxdepth: 3
:titlesonly:

关于 <about/index>
快速开始 <quick-start/index>
Expand Down
32 changes: 32 additions & 0 deletions docs/zh_CN/scripts/build-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

# Author: fasion
# Created time: 2019-11-04 09:34:59
# Last Modified by: fasion
# Last Modified time: 2019-11-05 10:31:01

SELF_PATH=`realpath "$0"`
SCRIPT_DIR_PATH=`dirname "$SELF_PATH"`
DOC_ROOT_PATH=`dirname "$SCRIPT_DIR_PATH"`
DOCS_PATH=`dirname "$DOC_ROOT_PATH"`
REPO_PATH=`dirname "$DOCS_PATH"`
VAR_PATH="$DOC_ROOT_PATH/var"
CLONE_PATH="$VAR_PATH/clone"

if [ -e "$CLONE_PATH" ]; then
read -p "delete clone repo $CLONE_PATH (y or n)? " value
if [ "$value" == "y" ]; then
rm -rf "$CLONE_PATH"
else
exit 1
fi
fi

git clone $REPO_PATH $CLONE_PATH

(
cd "$CLONE_PATH" && \
"$CLONE_PATH/docs/zh_CN/scripts/setup.sh" && \
"$CLONE_PATH/docs/zh_CN/scripts/build.sh" && \
ossutil -e oss-cn-shanghai.aliyuncs.com cp -f -r "$CLONE_PATH/docs/zh_CN/_build/html" oss://works-nodejs/zh_CN/latest
)
21 changes: 21 additions & 0 deletions docs/zh_CN/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

# Author: fasion
# Created time: 2019-11-04 08:38:35
# Last Modified by: fasion
# Last Modified time: 2019-11-04 08:44:15

SELF_PATH=`realpath "$0"`
SCRIPT_DIR_PATH=`dirname "$SELF_PATH"`
DOC_ROOT_PATH=`dirname "$SCRIPT_DIR_PATH"`
DOCS_PATH=`dirname "$DOC_ROOT_PATH"`
REPO_PATH=`dirname "$DOCS_PATH"`
PYENV_PATH="$DOC_ROOT_PATH/opt/pyenv"
PIP_PATH="$PYENV_PATH/bin/pip"
REAL_PYENV_PATH="$HOME/opt/pythons/pyenv.sphinx"
PYENV_BIN_PATH="$PYENV_PATH/bin"

(
cd "$DOC_ROOT_PATH"
PATH="$PATH:$PYENV_BIN_PATH" make html
)
33 changes: 33 additions & 0 deletions docs/zh_CN/scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
# FileName: setup.sh
# Author: Fasion Chan
# @contact: fasionchan@gmail.com
# @version: $Id$
#
# Description:
#
# Changelog:
#
#

SELF_PATH=`realpath "$0"`
SCRIPT_DIR_PATH=`dirname "$SELF_PATH"`
DOC_ROOT_PATH=`dirname "$SCRIPT_DIR_PATH"`
DOCS_PATH=`dirname "$DOC_ROOT_PATH"`
REPO_PATH=`dirname "$DOCS_PATH"`
PYENV_PATH="$DOC_ROOT_PATH/opt/pyenv"
PIP_PATH="$PYENV_PATH/bin/pip"
REAL_PYENV_PATH="$HOME/opt/pythons/pyenv.sphinx"

if [ ! -e "$REAL_PYENV_PATH" ]; then
mkdir -p "$REAL_PYENV_PATH"
virtualenv -p python3 "$REAL_PYENV_PATH"
fi

if [ ! -e "$PYENV_PATH" ]; then
mkdir -p `dirname "$PYENV_PATH"`
ln -s "$REAL_PYENV_PATH" "$PYENV_PATH"
fi

"$PIP_PATH" install -r "$REPO_PATH/requirements/docs.txt"
"$PIP_PATH" install -r "$REPO_PATH/requirements/docs-dev.txt"
2 changes: 1 addition & 1 deletion docs/zh_CN/stdlib/fs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
========

.. toctree::
:maxdepth: 3
:titlesonly:

文件读写 <read-write>
2 changes: 1 addition & 1 deletion docs/zh_CN/stdlib/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
======

.. toctree::
:maxdepth: 3
:titlesonly:

文件系统 <fs/index>

Expand Down
2 changes: 1 addition & 1 deletion docs/zh_CN/tour/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Node.js之旅
===========

.. toctree::
:maxdepth: 3
:titlesonly:

模块 <module>
HTTP模块 <http>
Expand Down
2 changes: 2 additions & 0 deletions readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
formats: []
requirements_file: requirements/docs.txt
1 change: 1 addition & 0 deletions requirements/docs-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sphinx-autobuild==0.7.1
2 changes: 2 additions & 0 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Sphinx==1.8.2
sphinx-sitemap==0.3.1

0 comments on commit 339956d

Please sign in to comment.