\/\/ \-/ ❭❬ 5 anos atrás
pai
commit
1822f74f96
5 arquivos alterados com 260 adições e 0 exclusões
  1. 86
    0
      Makefile
  2. 1
    0
      content/ag
  3. 36
    0
      pelicanconf.py
  4. 25
    0
      publishconf.py
  5. 112
    0
      tasks.py

+ 86
- 0
Makefile Ver arquivo

@@ -0,0 +1,86 @@
1
+PY?=python3
2
+PELICAN?=pelican
3
+PELICANOPTS=
4
+
5
+BASEDIR=$(CURDIR)
6
+INPUTDIR=$(BASEDIR)/content
7
+OUTPUTDIR=$(BASEDIR)/output
8
+CONFFILE=$(BASEDIR)/pelicanconf.py
9
+PUBLISHCONF=$(BASEDIR)/publishconf.py
10
+
11
+SSH_HOST=www2.frepoteries.fr
12
+SSH_PORT=22
13
+SSH_USER=www-git
14
+SSH_TARGET_DIR=/home/wwww-git/scop-cli
15
+
16
+
17
+DEBUG ?= 0
18
+ifeq ($(DEBUG), 1)
19
+	PELICANOPTS += -D
20
+endif
21
+
22
+RELATIVE ?= 0
23
+ifeq ($(RELATIVE), 1)
24
+	PELICANOPTS += --relative-urls
25
+endif
26
+
27
+help:
28
+	@echo 'Makefile for a pelican Web site                                           '
29
+	@echo '                                                                          '
30
+	@echo 'Usage:                                                                    '
31
+	@echo '   make html                           (re)generate the web site          '
32
+	@echo '   make clean                          remove the generated files         '
33
+	@echo '   make regenerate                     regenerate files upon modification '
34
+	@echo '   make publish                        generate using production settings '
35
+	@echo '   make serve [PORT=8000]              serve site at http://localhost:8000'
36
+	@echo '   make serve-global [SERVER=0.0.0.0]  serve (as root) to $(SERVER):80    '
37
+	@echo '   make devserver [PORT=8000]          serve and regenerate together      '
38
+	@echo '   make ssh_upload                     upload the web site via SSH        '
39
+	@echo '   make rsync_upload                   upload the web site via rsync+ssh  '
40
+	@echo '                                                                          '
41
+	@echo 'Set the DEBUG variable to 1 to enable debugging, e.g. make DEBUG=1 html   '
42
+	@echo 'Set the RELATIVE variable to 1 to enable relative urls                    '
43
+	@echo '                                                                          '
44
+
45
+html:
46
+	$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
47
+
48
+clean:
49
+	[ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR)
50
+
51
+regenerate:
52
+	$(PELICAN) -r $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
53
+
54
+serve:
55
+ifdef PORT
56
+	$(PELICAN) -l $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) -p $(PORT)
57
+else
58
+	$(PELICAN) -l $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
59
+endif
60
+
61
+serve-global:
62
+ifdef SERVER
63
+	$(PELICAN) -l $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) -p $(PORT) -b $(SERVER)
64
+else
65
+	$(PELICAN) -l $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) -p $(PORT) -b 0.0.0.0
66
+endif
67
+
68
+
69
+devserver:
70
+ifdef PORT
71
+	$(PELICAN) -lr $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) -p $(PORT)
72
+else
73
+	$(PELICAN) -lr $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
74
+endif
75
+
76
+publish:
77
+	$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(PUBLISHCONF) $(PELICANOPTS)
78
+
79
+ssh_upload: publish
80
+	scp -P $(SSH_PORT) -r $(OUTPUTDIR)/* $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
81
+
82
+rsync_upload: publish
83
+	rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --cvs-exclude --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
84
+
85
+
86
+.PHONY: html help clean regenerate serve serve-global devserver publish ssh_upload rsync_upload

+ 1
- 0
content/ag Ver arquivo

@@ -0,0 +1 @@
1
+/home/emixam/cloud/document/scop/ag/

+ 36
- 0
pelicanconf.py Ver arquivo

@@ -0,0 +1,36 @@
1
+#!/usr/bin/env python
2
+# -*- coding: utf-8 -*- #
3
+from __future__ import unicode_literals
4
+
5
+AUTHOR = 'maxime alves'
6
+SITENAME = 'scop cli'
7
+SITEURL = ''
8
+
9
+PATH = 'content'
10
+
11
+TIMEZONE = 'Europe/Paris'
12
+
13
+DEFAULT_LANG = 'fr'
14
+
15
+# Feed generation is usually not desired when developing
16
+FEED_ALL_ATOM = None
17
+CATEGORY_FEED_ATOM = None
18
+TRANSLATION_FEED_ATOM = None
19
+AUTHOR_FEED_ATOM = None
20
+AUTHOR_FEED_RSS = None
21
+
22
+# Blogroll
23
+#LINKS = (('Pelican', 'http://getpelican.com/'),
24
+#         ('Python.org', 'http://python.org/'),
25
+#         ('Jinja2', 'http://jinja.pocoo.org/'),
26
+#         ('You can modify those links in your config file', '#'),)
27
+
28
+# Social widget
29
+#SOCIAL = (('You can add links in your config file', '#'),
30
+#          ('Another social link', '#'),)
31
+
32
+DEFAULT_PAGINATION = 3
33
+
34
+# Uncomment following line if you want document-relative URLs when developing
35
+#RELATIVE_URLS = True
36
+MD_EXTENSION =  []

+ 25
- 0
publishconf.py Ver arquivo

@@ -0,0 +1,25 @@
1
+#!/usr/bin/env python
2
+# -*- coding: utf-8 -*- #
3
+from __future__ import unicode_literals
4
+
5
+# This file is only used if you use `make publish` or
6
+# explicitly specify it as your config file.
7
+
8
+import os
9
+import sys
10
+sys.path.append(os.curdir)
11
+from pelicanconf import *
12
+
13
+# If your site is available via HTTPS, make sure SITEURL begins with https://
14
+SITEURL = ''
15
+RELATIVE_URLS = False
16
+
17
+FEED_ALL_ATOM = 'feeds/all.atom.xml'
18
+CATEGORY_FEED_ATOM = 'feeds/{slug}.atom.xml'
19
+
20
+DELETE_OUTPUT_DIRECTORY = True
21
+
22
+# Following items are often useful when publishing
23
+
24
+#DISQUS_SITENAME = ""
25
+#GOOGLE_ANALYTICS = ""

+ 112
- 0
tasks.py Ver arquivo

@@ -0,0 +1,112 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+import os
4
+import shutil
5
+import sys
6
+import datetime
7
+
8
+from invoke import task
9
+from invoke.util import cd
10
+from pelican.server import ComplexHTTPRequestHandler, RootedHTTPServer
11
+from pelican.settings import DEFAULT_CONFIG, get_settings_from_file
12
+
13
+SETTINGS_FILE_BASE = 'pelicanconf.py'
14
+SETTINGS = {}
15
+SETTINGS.update(DEFAULT_CONFIG)
16
+LOCAL_SETTINGS = get_settings_from_file(SETTINGS_FILE_BASE)
17
+SETTINGS.update(LOCAL_SETTINGS)
18
+
19
+CONFIG = {
20
+    'settings_base': SETTINGS_FILE_BASE,
21
+    'settings_publish': 'publishconf.py',
22
+    # Output path. Can be absolute or relative to tasks.py. Default: 'output'
23
+    'deploy_path': SETTINGS['OUTPUT_PATH'],
24
+    # Remote server configuration
25
+    'production': 'www-git@www2.frepoteries.fr:22',
26
+    'dest_path': '/home/wwww-git/scop-cli',
27
+    # Port for `serve`
28
+    'port': 8000,
29
+}
30
+
31
+@task
32
+def clean(c):
33
+    """Remove generated files"""
34
+    if os.path.isdir(CONFIG['deploy_path']):
35
+        shutil.rmtree(CONFIG['deploy_path'])
36
+        os.makedirs(CONFIG['deploy_path'])
37
+
38
+@task
39
+def build(c):
40
+    """Build local version of site"""
41
+    c.run('pelican -s {settings_base}'.format(**CONFIG))
42
+
43
+@task
44
+def rebuild(c):
45
+    """`build` with the delete switch"""
46
+    c.run('pelican -d -s {settings_base}'.format(**CONFIG))
47
+
48
+@task
49
+def regenerate(c):
50
+    """Automatically regenerate site upon file modification"""
51
+    c.run('pelican -r -s {settings_base}'.format(**CONFIG))
52
+
53
+@task
54
+def serve(c):
55
+    """Serve site at http://localhost:$PORT/ (default port is 8000)"""
56
+
57
+    class AddressReuseTCPServer(RootedHTTPServer):
58
+        allow_reuse_address = True
59
+
60
+    server = AddressReuseTCPServer(
61
+        CONFIG['deploy_path'],
62
+        ('', CONFIG['port']),
63
+        ComplexHTTPRequestHandler)
64
+
65
+    sys.stderr.write('Serving on port {port} ...\n'.format(**CONFIG))
66
+    server.serve_forever()
67
+
68
+@task
69
+def reserve(c):
70
+    """`build`, then `serve`"""
71
+    build(c)
72
+    serve(c)
73
+
74
+@task
75
+def preview(c):
76
+    """Build production version of site"""
77
+    c.run('pelican -s {settings_publish}'.format(**CONFIG))
78
+
79
+@task
80
+def livereload(c):
81
+    """Automatically reload browser tab upon file modification."""
82
+    from livereload import Server
83
+    build(c)
84
+    server = Server()
85
+    # Watch the base settings file
86
+    server.watch(CONFIG['settings_base'], lambda: build(c))
87
+    # Watch content source files
88
+    content_file_extensions = ['.md', '.rst']
89
+    for extension in content_file_extensions:
90
+        content_blob = '{0}/**/*{1}'.format(SETTINGS['PATH'], extension)
91
+        server.watch(content_blob, lambda: build(c))
92
+    # Watch the theme's templates and static assets
93
+    theme_path = SETTINGS['THEME']
94
+    server.watch('{}/templates/*.html'.format(theme_path), lambda: build(c))
95
+    static_file_extensions = ['.css', '.js']
96
+    for extension in static_file_extensions:
97
+        static_file = '{0}/static/**/*{1}'.format(theme_path, extension)
98
+        server.watch(static_file, lambda: build(c))
99
+    # Serve output path on configured port
100
+    server.serve(port=CONFIG['port'], root=CONFIG['deploy_path'])
101
+
102
+
103
+@task
104
+def publish(c):
105
+    """Publish to production via rsync"""
106
+    c.run('pelican -s {settings_publish}'.format(**CONFIG))
107
+    c.run(
108
+        'rsync --delete --exclude ".DS_Store" -pthrvz -c '
109
+        '{} {production}:{dest_path}'.format(
110
+            CONFIG['deploy_path'].rstrip('/') + '/',
111
+            **CONFIG))
112
+

Carregando…
Cancelar
Salvar