summaryrefslogtreecommitdiff
blob: 8e75b54478cb84fdbf41a80c554640fe418c0e8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=5
PYTHON_COMPAT=( python2_7 ) # 3_3 needs PyRSS2Gen update
inherit distutils-r1

DESCRIPTION="A static website and blog generator"
HOMEPAGE="http://getnikola.com/"
MY_PN="Nikola"

if [[ ${PV} == *9999* ]]; then
	inherit git-3
	EGIT_REPO_URI="git://github.com/getnikola/${PN}.git"
	KEYWORDS=""
else
	SRC_URI="mirror://pypi/${MY_PN:0:1}/${MY_PN}/${P}.tar.gz"
	KEYWORDS="~amd64"
fi

# Apache-2.0: bootstrap.{css,js}
# CC-BY-NC-SA-2.5: conf.py.in
LICENSE="MIT-with-advertising Apache-2.0 CC-BY-NC-SA-2.5"
SLOT="0"
IUSE="assets charts hyphenation ipython jinja markdown minimal"
RESTRICT=test

# needs rst2man to build manpage
DEPEND="dev-python/docutils
	dev-python/setuptools[${PYTHON_USEDEP}]"
RDEPEND="app-arch/gzip
	python_targets_python2_7? ( >=dev-python/configparser-3.2.0[python_targets_python2_7] )
	dev-python/blinker[${PYTHON_USEDEP}]
	dev-python/docutils[${PYTHON_USEDEP}]
	>=dev-python/doit-0.23.0[${PYTHON_USEDEP}]
	dev-python/logbook[${PYTHON_USEDEP}]
	dev-python/lxml[${PYTHON_USEDEP}]
	>=dev-python/mako-0.6[${PYTHON_USEDEP}]
	dev-python/pygments[${PYTHON_USEDEP}]
	dev-python/PyRSS2Gen[${PYTHON_USEDEP}]
	>=dev-python/pytz-2013d[${PYTHON_USEDEP}]
	dev-python/unidecode[${PYTHON_USEDEP}]
	>=dev-python/yapsy-1.10.2[${PYTHON_USEDEP}]
	>=virtual/python-imaging-2[${PYTHON_USEDEP}]
	assets? ( dev-python/assets[${PYTHON_USEDEP}] )
	charts? ( dev-python/pygal[${PYTHON_USEDEP}] )
	hyphenation? ( dev-python/pyphen[${PYTHON_USEDEP}] )
	ipython? ( >=dev-python/ipython-1.0.0[${PYTHON_USEDEP}] )
	jinja? ( >=dev-python/jinja-2.7[${PYTHON_USEDEP}] )
	markdown? ( dev-python/markdown[${PYTHON_USEDEP}] )
	!minimal? ( dev-python/colorama[${PYTHON_USEDEP}]
		dev-python/python-dateutil[${PYTHON_USEDEP}]
		>=dev-python/requests-1.0[${PYTHON_USEDEP}] )"
### test:
# dev-python/coverage
# dev-python/freezegun # not in gentoo
# >=dev-python/mock-1.0.0
# dev-python/nose
# dev-python/python-coveralls # not in gentoo
# dev-python/flake8
# pip?
# dev-python/phpserialize # XXX # not in gentoo

DOCS=( AUTHORS.txt CHANGES.txt CONTRIBUTING.rst README.rst )

# from net-misc/netctl
optfeature() {
	local desc=$1
	shift
	while (( $# )); do
		if has_version "$1"; then
			elog "  [I] $1 for ${desc}"
		else
			elog "  [ ] $1 for ${desc}"
		fi
		 shift
	done
}

# used for src_test()
checkpythonlocale() {
	${PYTHON} <<-EOF
		import locale
		locale.setlocale(locale.LC_ALL, '${1}')
		EOF
	return $?
}

src_prepare() {
	# Redact non-public-domain parts
	# http://www.gutenberg.org/wiki/Gutenberg:The_Project_Gutenberg_License
	sed -e '/Posting Date/d' \
		-e '/Release Date/d' \
		-e '/Produced By/d' \
		-e '/note::/s:The Project Gutenberg EBook of ::' \
		-e '/This eBook is for the use/,/Part II, The Country of the Saints/d' \
		-e '/END OF THIS PROJECT GUTENBERG EBOOK/,$d' \
		-i nikola/data/samplesite/stories/a-study-in-scarlet.txt || die
	grep -Ei 'gutenberg|license' nikola/data/samplesite/stories/a-study-in-scarlet.txt && die "Redaction failed."
}

# Unfinished, due to phpserialize dependency.
python_test() {
	if ! checkpythonlocale en_US.utf8 || ! checkpythonlocale pl_PL.utf8 ; then
		ewarn "Skipping tests due to locales en_US.utf8 and pl_PL.utf8 not usable by ${EPYTHON}."
		return 0
	fi
	nosetests \
		--with-coverage --cover-package=nikola \
		--with-doctest --doctest-options=+NORMALIZE_WHITESPACE \
		--logging-filter=-yapsy || die 'nosetests failed'
}

src_install() {
	distutils-r1_src_install

	# hackish way to remove docs that ended up in the wrong place
	rm -rf "${D}"/usr/share/doc/${PN}

	dodoc docs/*.txt
}

pkg_postinst() {
	# workaround until https://bugs.gentoo.org/453618
	elog "For additional features, a number of optional runtime dependencies may be"
	elog "installed. Note that dependencies marked with (*) need to be installed for the"
	elog "python interpreter you are using, or their functionality will not be available."

#	optfeature "Compiling BBCode into html (*)" dev-python/bbcode # not in gentoo
	optfeature "Compiling IPython notebooks into HTML (*)" ">=dev-python/ipython-1.0.0"
	optfeature "Jinja2 template support (*)" ">=dev-python/jinja-2.7" # currently use flag
	optfeature "Compiling Markdown into HTML (*)" dev-python/markdown # currently use flag

	optfeature "Colorized log messages (*)" dev-python/colorama
#	optfeature "Embedding media from many websites (*)" dev-python/micawber # not in gentoo
	optfeature "Downloading files while importing WordPress dumps (*)" dev-python/phpserialize ">=dev-python/requests-1.0" # not in gentoo
	optfeature "Producing SVG charts for embedding (*)" dev-python/pygal # currently use flag
	optfeature "Hyphenation (*)" dev-python/pyphen
	optfeature "Enhanced date format parsing (*)" dev-python/python-dateutil # currently use flag
#	optfeature "Automatically rebuilding site on file changes (*)" >=dev-python/python-livereload-2.1.0 # not in gentoo
	optfeature "Installing plugins and themes (*)" ">=dev-python/requests-1.0" # currently use flag
	optfeature "Embedding media from Vimeo (*)" ">=dev-python/requests-1.0" # currently use flag
	optfeature "Inline source code from GIST (*)" ">=dev-python/requests-1.0" # currently use flag

#	optfeature "Yielding typographically-improved HTML (*)" ">=dev-python/typogrify-2.0.4" # not in gentoo
	optfeature "Making bundles of theme CSS and js (*)" dev-python/assets # currently use flag # no python3_3 support

### Not mentioned in requirements*.txt:
	optfeature "Compiling asciidoc documents into HTML" app-text/asciidoc # executable
	optfeature "Compiling Textile into HTML (*)" app-text/pytextile # old python eclass
#	optfeature "Compiling reStructuredText into HTML (*)" dev-python/docutils # not optional
	optfeature "Compiling misaka markdown documents to HTML (*)" dev-python/misaka # no python3_3 support
	optfeature "Compiling txt2tags documents to HTML (*)" app-text/txt2tags # old python eclas
#	optfeature "Compiling CreoleWiki to HTML (*)" dev-python/creole # not in gentoo
	optfeature "Compiling various documents into HTML" app-text/pandoc # executable

	optfeature "Importing Atom/RSS feeds and Blogger dumps (*)" dev-python/feedparser
	optfeature "Feed aggregation (*)" dev-python/peewee # no python3_3 support
#	optfeature "Rendering galleries (*)" ">=virtual/python-imaging-2" # not optional

	optfeature "Tidying up HTML" app-text/htmltidy # executable
#	optfeature "Compressing CSS and js" app-text/yuicompressor # executable # not in gentoo
#	optfeature "Removing unused and redundant CSS (*)" dev-python/mincss # not in gentoo
	optfeature "Optimizing JPEG images" media-gfx/jpegoptim # executable
	optfeature "Optimizing PNG images" media-gfx/optipng # executable
	optfeature "Building CSS from Sass sources" dev-ruby/sass # executable
#	optfeature "Building CSS from LESS sources" www-apps/less # executable lessc # not in gentoo, bundled in ipython, meteor
}