From 96ad738abc403d81a05d5a341d43fa33595fecbf Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Fri, 19 Apr 2019 21:34:58 +0300 Subject: [PATCH] Init --- .gitignore | 5 + .gitmodules | 9 ++ README.md | 20 ++++ pelicanconf.py | 106 +++++++++++++++++++ plugins/official | 1 + plugins/thirdparty/md-metayaml | 1 + plugins/thirdparty/pelican-css | 1 + publishconf.py | 25 +++++ tasks.py | 80 ++++++++++++++ wiki/Prog/Git/Git замена адреса подмодуля.md | 22 ++++ wiki/Prog/Git/Git распаковка объекта.md | 16 +++ 11 files changed, 286 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 README.md create mode 100644 pelicanconf.py create mode 160000 plugins/official create mode 160000 plugins/thirdparty/md-metayaml create mode 160000 plugins/thirdparty/pelican-css create mode 100644 publishconf.py create mode 100644 tasks.py create mode 100644 wiki/Prog/Git/Git замена адреса подмодуля.md create mode 100644 wiki/Prog/Git/Git распаковка объекта.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3891979 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +cache/* +output/* +__pycache__ + + diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..7c328f9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "plugins/thirdparty/md-metayaml"] + path = plugins/thirdparty/md-metayaml + url = git@git.246060.ru:/f1x1t/pelican-md-metayaml.git +[submodule "plugins/thirdparty/pelican-css"] + path = plugins/thirdparty/pelican-css + url = https://notabug.org/jorgesumle/pelican-css +[submodule "plugins/official"] + path = plugins/official + url = git@github.com:/getpelican/pelican-plugins.git diff --git a/README.md b/README.md new file mode 100644 index 0000000..27c5208 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +Сайт ДСП +======== + +Установка: + +```sh +git clone git@git.246060.ru:/f1x1t/dsp-site dsp-site +cd dsp-site +git submodule update --init --recursive plugins/thirdparty/md-metayaml +git submodule update --init plugins/official +git submodule update --init plugins/thirdparty/pelican-css +git submodule update --init themes/bootstrap4 +``` + +Первую компиляцию нужно выполнить без учёта кэша: + +```sh +pelican --ignore-cache +``` + diff --git a/pelicanconf.py b/pelicanconf.py new file mode 100644 index 0000000..43fec96 --- /dev/null +++ b/pelicanconf.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- # +from __future__ import unicode_literals + +class i18n(object): + # looks for translations in + # {LOCALE_DIR}/{LANGUAGE}/LC_MESSAGES/{DOMAIN}.mo + # if not present, falls back to default + + DOMAIN = 'messages' + LOCALE_DIR = '{THEME}/translations' + LANGUAGES = ['ru'] + NEWSTYLE = True + + __name__ = 'i18n' + + def register(self): + from pelican.signals import generator_init + generator_init.connect(self.install_translator) + + def install_translator(self, generator): + import gettext + try: + translator = gettext.translation( + self.DOMAIN, + self.LOCALE_DIR.format(THEME=THEME), + self.LANGUAGES) + except (OSError, IOError): + translator = gettext.NullTranslations() + generator.env.install_gettext_translations(translator, self.NEWSTYLE) + +AUTHOR = 'Андрей Астафьев' +SITENAME = 'ДСП' +SITEURL = 'https://dsp.246060.ru' +PORT = 33322 + +PATH = 'wiki' + +TIMEZONE = 'Europe/Moscow' + +DEFAULT_LANG = 'ru' + +# Generation time +CACHE_CONTENT = True +LOAD_CONTENT_CACHE = True + +# Feed generation is usually not desired when developing +FEED_ALL_ATOM = None +CATEGORY_FEED_ATOM = None +TRANSLATION_FEED_ATOM = None +AUTHOR_FEED_ATOM = None +AUTHOR_FEED_RSS = None +USE_FOLDER_AS_CATEGORY = True +DEFAULT_DATE = 'fs' +STATIC_PATHS = [ 'images', 'files' ] + +MARKDOWN = { + 'extension_configs': { + 'markdown.extensions.codehilite': {'css_class': 'highlight'}, + 'markdown.extensions.extra': {}, + 'markdown.extensions.meta': {}, + }, + 'output_format': 'html5', +} + +DISPLAY_CATEGORIES_ON_MENU = False +DISPLAY_CATEGORIES_ON_SIDEBAR = True +DISPLAY_TAGS_ON_SIDEBAR = True + +THEME = 'themes/bootstrap4' +BOOTSTRAP_THEME = 'litera' + +I18N_TEMPLATES_LANG = 'ru' +I18N_GETTEXT_NEWSTYLE = True +I18N_GETTEXT_LOCALEDIR = 'themes/bootstrap4/translations' +I18N_GETTEXT_DOMAIN = 'messages' +JINJA_ENVIRONMENT = {'extensions': ['jinja2.ext.i18n']} + +PLUGIN_PATHS = ["plugins/official", "plugins/thirdparty"] +PLUGINS = [i18n(), "md-metayaml", "render_math", "series", "subcategory", "tag_cloud", "tipue_search", "pelican-css"] +#PLUGINS = ["better_tables", "just_table"] + +YUICOMPRESSOR_EXECUTABLE = "yui-compressor" +PLUGINS += ["yuicompressor"] + +DIRECT_TEMPLATES = ('index', 'categories', 'authors', 'archives', 'search') + +# Blogroll +LINKS = () +# LINKS = (('Pelican', 'http://getpelican.com/'), +# ('Python.org', 'http://python.org/'), +# ('Jinja2', 'http://jinja.pocoo.org/'), +# ('You can modify those links in your config file', '#'),) + +# Social widget +SOCIAL = () +# SOCIAL = (('You can add links in your config file', '#'), +# ('Another social link', '#'),) + +PYGMENTS_STYLE='pastie' + +DEFAULT_PAGINATION = 20 + +# Uncomment following line if you want document-relative URLs when developing +RELATIVE_URLS = True + diff --git a/plugins/official b/plugins/official new file mode 160000 index 0000000..cfc7a3f --- /dev/null +++ b/plugins/official @@ -0,0 +1 @@ +Subproject commit cfc7a3f224f1743063b034561f89a6a712d13587 diff --git a/plugins/thirdparty/md-metayaml b/plugins/thirdparty/md-metayaml new file mode 160000 index 0000000..37143ae --- /dev/null +++ b/plugins/thirdparty/md-metayaml @@ -0,0 +1 @@ +Subproject commit 37143ae6e114e5f5e8a2ba782cb87f87f760d193 diff --git a/plugins/thirdparty/pelican-css b/plugins/thirdparty/pelican-css new file mode 160000 index 0000000..5d6009d --- /dev/null +++ b/plugins/thirdparty/pelican-css @@ -0,0 +1 @@ +Subproject commit 5d6009dcf558004b5bb3686f9b8ee269a398fb6b diff --git a/publishconf.py b/publishconf.py new file mode 100644 index 0000000..451f2b3 --- /dev/null +++ b/publishconf.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- # +from __future__ import unicode_literals + +# This file is only used if you use `make publish` or +# explicitly specify it as your config file. + +import os +import sys +sys.path.append(os.curdir) +from pelicanconf import * + +# If your site is available via HTTPS, make sure SITEURL begins with https:// +SITEURL = 'https://dsp.246060.ru' +RELATIVE_URLS = True + +FEED_ALL_ATOM = 'feeds/all.atom.xml' +CATEGORY_FEED_ATOM = 'feeds/{slug}.atom.xml' + +DELETE_OUTPUT_DIRECTORY = True + +# Following items are often useful when publishing + +#DISQUS_SITENAME = "" +#GOOGLE_ANALYTICS = "" \ No newline at end of file diff --git a/tasks.py b/tasks.py new file mode 100644 index 0000000..a6aa37e --- /dev/null +++ b/tasks.py @@ -0,0 +1,80 @@ +# -*- coding: utf-8 -*- + +import os +import shutil +import sys +import datetime + +from invoke import task +from invoke.util import cd +from pelican.server import ComplexHTTPRequestHandler, RootedHTTPServer + +CONFIG = { + # Local path configuration (can be absolute or relative to tasks.py) + 'deploy_path': 'output', + # Remote server configuration + 'production': 'root@localhost:22', + 'dest_path': '/var/www', + # Port for `serve` + 'port': 8000, +} + +@task +def clean(c): + """Remove generated files""" + if os.path.isdir(CONFIG['deploy_path']): + shutil.rmtree(CONFIG['deploy_path']) + os.makedirs(CONFIG['deploy_path']) + +@task +def build(c): + """Build local version of site""" + c.run('pelican -s pelicanconf.py') + +@task +def rebuild(c): + """`build` with the delete switch""" + c.run('pelican -d -s pelicanconf.py') + +@task +def regenerate(c): + """Automatically regenerate site upon file modification""" + c.run('pelican -r -s pelicanconf.py') + +@task +def serve(c): + """Serve site at http://localhost:8000/""" + + class AddressReuseTCPServer(RootedHTTPServer): + allow_reuse_address = True + + server = AddressReuseTCPServer( + CONFIG['deploy_path'], + ('', CONFIG['port']), + ComplexHTTPRequestHandler) + + sys.stderr.write('Serving on port {port} ...\n'.format(**CONFIG)) + server.serve_forever() + +@task +def reserve(c): + """`build`, then `serve`""" + build(c) + serve(c) + +@task +def preview(c): + """Build production version of site""" + c.run('pelican -s publishconf.py') + + +@task +def publish(c): + """Publish to production via rsync""" + c.run('pelican -s publishconf.py') + c.run( + 'rsync --delete --exclude ".DS_Store" -pthrvz -c ' + '{} {production}:{dest_path}'.format( + CONFIG['deploy_path'].rstrip('/') + '/', + **CONFIG)) + diff --git a/wiki/Prog/Git/Git замена адреса подмодуля.md b/wiki/Prog/Git/Git замена адреса подмодуля.md new file mode 100644 index 0000000..7b86704 --- /dev/null +++ b/wiki/Prog/Git/Git замена адреса подмодуля.md @@ -0,0 +1,22 @@ +# Git: замена адреса подмодуля + +--- +title: "Git: замена адреса подмодуля" +category: Программирование +tags: программирование, git +summary: +CSS: table-100.css +... + + +Если у подмодуля `thirdparty/example` нужно заменить адрес синхронизации +и имя используемой ветки, то в каталоге с файлом `.gitmodules`, в котором +содержится информация об этом подмодуле, нужно выполнить команды: + +```sh +git config --file=.gitmodules submodule.thirdparty/example.url https://github.com/username/ABC.git +git config --file=.gitmodules submodule.thirdparty/example.branch new-branch-name +git submodule sync +git submodule update --init --recursive --remote +``` + diff --git a/wiki/Prog/Git/Git распаковка объекта.md b/wiki/Prog/Git/Git распаковка объекта.md new file mode 100644 index 0000000..19a86a5 --- /dev/null +++ b/wiki/Prog/Git/Git распаковка объекта.md @@ -0,0 +1,16 @@ +# Git: распаковка объекта + +--- +title: "Git: распаковка объекта" +category: Программирование +tags: программирование, git +summary: +CSS: table-100.css +... + +В случае повреждения репозитория можно восстановить отдельные +объекты, которые сохраняются в формате zlib. Пример команды: + +``` +perl -MCompress::Zlib -e 'undef $/; print uncompress(<>)' < 1234567890abcdef1234567890abcdef012345 > file +```