a few updates since last commit
This commit is contained in:
parent
dae95027aa
commit
33a1a23ad4
8 changed files with 80 additions and 203 deletions
|
|
@ -1,43 +0,0 @@
|
|||
This **EXPERIMENTAL** plugin tries to make it easy to keep your site in a version control system.
|
||||
|
||||
**There are problems in the anyvc support of python 3. So, use this only in python2 until
|
||||
I figure that out.**
|
||||
|
||||
**REMEMBER**, this is a first iteration, it's probably buggy, so be careful, and only use it
|
||||
if you are experienced with your VCS, ok?
|
||||
|
||||
How to use it:
|
||||
|
||||
1. Choose your favourite VCS between git, bzr, subversion, mercurial.
|
||||
2. Initialize the repo in your site (for example: ``git init .``)
|
||||
3. Install this plugin: ``nikola plugin -i vcs``
|
||||
4. Run ``nikola vcs``
|
||||
5. Check what happened (for example: ``git status`` and ``git log``)
|
||||
6. Use your site as usual, creating posts, adding stuff or removing it
|
||||
7. GOTO 4.
|
||||
8. You may want to add ``nikola vcs`` to your deploy commands.
|
||||
|
||||
What it should do:
|
||||
|
||||
1. Add a lot of stuff to the repo:
|
||||
|
||||
* All your posts
|
||||
* All your pages
|
||||
* All your galleries' images
|
||||
* All your listings
|
||||
* All your static files
|
||||
* Your themes
|
||||
* Your plugins
|
||||
* Your conf.py
|
||||
|
||||
2. Remove stuff if you removed it
|
||||
3. Commit stuff if you changed it
|
||||
|
||||
What it should **NOT** do:
|
||||
|
||||
1. Lose your data
|
||||
2. Push it anywhere (yet)
|
||||
3. Manage your output (consider ``github_deploy`` would not like it!)
|
||||
|
||||
Please report anything missing, or any ideas on how to improve this, where you want this to go
|
||||
by [filing issues](https://github.com/getnikola/plugins/issues).
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
anyvc
|
||||
py
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
[Core]
|
||||
Name = vcs
|
||||
Module = vcs
|
||||
|
||||
[Documentation]
|
||||
Author = Roberto Alsina
|
||||
Version = 1.0
|
||||
Website = https://getnikola.com
|
||||
Description = Site vcs
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright © 2015 Roberto Alsina.
|
||||
|
||||
# Permission is hereby granted, free of charge, to any
|
||||
# person obtaining a copy of this software and associated
|
||||
# documentation files (the "Software"), to deal in the
|
||||
# Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the
|
||||
# Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice
|
||||
# shall be included in all copies or substantial portions of
|
||||
# the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
||||
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||
# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import print_function
|
||||
import os
|
||||
|
||||
from py.path import local
|
||||
from anyvc import workdir
|
||||
|
||||
from nikola.plugin_categories import Command
|
||||
from nikola.utils import get_logger
|
||||
|
||||
|
||||
def get_path_list(path):
|
||||
'''Walk path and return a list of everything in it.'''
|
||||
paths = []
|
||||
for root, dirs, files in os.walk(path, followlinks=True):
|
||||
for fname in files:
|
||||
fpath = os.path.join(root, fname)
|
||||
paths.append(fpath)
|
||||
return list(set(paths))
|
||||
|
||||
|
||||
class CommandVCS(Command):
|
||||
""" Site status. """
|
||||
name = "vcs"
|
||||
|
||||
doc_purpose = "display site status"
|
||||
doc_description = "Show information about the posts and site deployment."
|
||||
logger = None
|
||||
cmd_options = []
|
||||
|
||||
def _execute(self, options, args):
|
||||
logger = get_logger('vcs', self.site.loghandlers)
|
||||
self.site.scan_posts()
|
||||
|
||||
repo_path = local('.')
|
||||
wd = workdir.open(repo_path)
|
||||
|
||||
# See if anything got deleted
|
||||
del_paths = []
|
||||
flag = False
|
||||
for s in wd.status():
|
||||
if s.state == 'removed':
|
||||
if not flag:
|
||||
logger.info('Found deleted files')
|
||||
flag = True
|
||||
logger.info('DEL => {}', s.relpath)
|
||||
del_paths.append(s.relpath)
|
||||
|
||||
if flag:
|
||||
logger.info('Marking as deleted')
|
||||
wd.remove(paths=del_paths)
|
||||
wd.commit(message='Deleted Files', paths=del_paths)
|
||||
|
||||
# Collect all paths that should be kept under control
|
||||
# Post and page sources
|
||||
paths = []
|
||||
for lang in self.site.config['TRANSLATIONS']:
|
||||
for p in self.site.timeline:
|
||||
paths.extend(p.fragment_deps(lang))
|
||||
|
||||
# Files in general
|
||||
for k, v in self.site.config['FILES_FOLDERS'].items():
|
||||
paths.extend(get_path_list(k))
|
||||
for k, v in self.site.config['LISTINGS_FOLDERS'].items():
|
||||
paths.extend(get_path_list(k))
|
||||
for k, v in self.site.config['GALLERY_FOLDERS'].items():
|
||||
paths.extend(get_path_list(k))
|
||||
|
||||
# Themes and plugins
|
||||
for p in ['plugins', 'themes']:
|
||||
paths.extend(get_path_list(p))
|
||||
|
||||
# The configuration
|
||||
paths.extend('conf.py')
|
||||
|
||||
# Add them to the VCS
|
||||
paths = list(set(paths))
|
||||
wd.add(paths=paths)
|
||||
|
||||
flag = False
|
||||
for s in wd.status():
|
||||
if s.state == 'added':
|
||||
if not flag:
|
||||
logger.info('Found new files')
|
||||
flag = True
|
||||
logger.info('NEW => {}', s.relpath)
|
||||
|
||||
logger.info('Committing changes')
|
||||
wd.commit(message='Updated files')
|
||||
Loading…
Add table
Add a link
Reference in a new issue