-
Notifications
You must be signed in to change notification settings - Fork 153
/
dev.xml
305 lines (272 loc) · 10 KB
/
dev.xml
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<?xml version='1.0' encoding='UTF-8'?>
<dev><file for="vagrant"><path>Vagrantfile</path>
<contents>Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-20.04"
config.vm.box_check_update = false
config.vm.provision :shell, :path =&gt; "bootstrap.sh", privileged: false
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder "../django-markdownx", "/srv/django-markdownx", create: true
config.vm.network :forwarded_port, guest: 8000, host: 8000
config.vm.hostname = "django-markdownx"
config.ssh.forward_agent = true
config.vm.provider "virtualbox" do |vb|
vb.name = "django-markdownx"
vb.gui = false
vb.memory = "512"
vb.cpus = 2
vb.customize ["modifyvm", :id, "--ioapic", "on"]
end
end
</contents>
</file>
<file for="vagrant"><path>bootstrap.sh</path>
<contents>#!/usr/bin/env bash
# NOTE: Python alias
alias python=python3
# NOTE: Add Node.js APT Repository
sudo apt-get install -y curl
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
# NOTE: Install dependencies
sudo apt-get update -y
sudo apt-get install -y gettext build-essential pkg-config nodejs python3-dev libjpeg-dev zlib1g-dev python3-virtualenv
# NOTE: Install virtual environment
virtualenv ~/.virtualenvs/django-markdownx
source ~/.virtualenvs/django-markdownx/bin/activate
pip install --upgrade pip
pip install -r /srv/django-markdownx/requirements.txt
# NOTE: Folders
sudo chown vagrant:vagrant /srv
# NOTE: Bash
sudo sed -i '$a cd /srv/django-markdownx/' ~/.bashrc
sudo sed -i '$a source ~/.virtualenvs/django-markdownx/bin/activate' ~/.bashrc
# NOTE: Install Node modules, compile static files and run migrations
cd /srv/django-markdownx/
npm install
npm run dist
python manage.py migrate
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', '[email protected]', 'admin')" | python manage.py shell
echo -e '\e[33;1;5mDONE!\e[0m \e[33;1;3m Connect using "vagrant ssh" \e[0m'
</contents>
</file>
<file for="vagrant;docker;npm"><path>package.json</path>
<contents>{
"name": "django-markdownx",
"description": "Django Markdownx frontend (JavaScript).",
"version": "2.0.0",
"author": "Adi, Pouria Hadjibagheri",
"license": "2-clause BSD",
"engines": {
"node": "&gt;=0.10",
"npm": "&gt;=1.3"
},
"devDependencies": {
"watch": "~1",
"typescript": "~2.2",
"uglify-js": "~2.7",
"browserify": "~14.1",
"clean-css-cli": "~4"
},
"config": {
"tsfolder": "static-src/markdownx/js",
"jsoutput": "markdownx/static/markdownx/js",
"cssfolder": "static-src/markdownx/admin/css",
"cssoutput": "markdownx/static/markdownx/admin/css"
},
"scripts": {
"build:ts": "tsc -p $npm_package_config_tsfolder/tsconfig.json",
"build:js": "npm run build:ts &amp;&amp; browserify $npm_package_config_tsfolder/markdownx.js -o $npm_package_config_jsoutput/markdownx.js &amp;&amp; uglifyjs $npm_package_config_jsoutput/markdownx.js -o $npm_package_config_jsoutput/markdownx.js --beautify --stats",
"build:css": "cleancss $npm_package_config_cssfolder/markdownx.css -o $npm_package_config_cssoutput/markdownx.css --format beautify --debug",
"build": "npm run build:js &amp;&amp; npm run build:css",
"dist:js": "npm run build:ts &amp;&amp; browserify $npm_package_config_tsfolder/markdownx.js -o $npm_package_config_jsoutput/markdownx.js &amp;&amp; uglifyjs $npm_package_config_jsoutput/markdownx.js -o $npm_package_config_jsoutput/markdownx.min.js --screw-ie8 --mangle --stats",
"dist:css": "npm run build:css &amp;&amp; cleancss $npm_package_config_cssfolder/markdownx.css -o $npm_package_config_cssoutput/markdownx.min.css --compatibility ie9 --debug",
"dist": "npm run dist:js &amp;&amp; npm run dist:css",
"watch:js": "watch 'npm run build:js' $npm_package_config_tsfolder -d -u",
"watch:css": "watch 'npm run build:css' $npm_package_config_cssfolder -d -u"
}
}
</contents>
</file>
<file for="vagrant;docker;no-container"><path>runtests.py</path>
<contents>from __future__ import absolute_import
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), 'markdownx'))
import django
from django.conf import settings
configure_settings = {
'DATABASES': {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
},
'INSTALLED_APPS': [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.staticfiles',
'markdownx',
],
'DEBUG': False,
'STATIC_URL': '/static/',
'TEMPLATES': [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(os.path.abspath(os.path.dirname(__file__)), 'markdownx/tests/templates'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
],
'debug': True,
},
},
],
'ROOT_URLCONF': 'tests.urls',
}
settings.configure(**configure_settings)
django.setup()
from django.test.utils import get_runner
test_runner = get_runner(settings)
failures = test_runner(
verbosity=1,
interactive=False,
failfast=False).run_tests(['tests'])
sys.exit(failures)</contents>
</file>
<file for="docs"><path>create_docs.sh</path>
<contents>#!/usr/bin/env bash
# Compile the docs.
mkdocs build
# Open in the browser.
URL="docs/index.html"
echo "Documentations index file: $URL"
"" &gt;&gt; ./docs/.nojekyll
[[ -x $BROWSER ]] &amp;&amp; exec "$BROWSER" "$URL"
path=$(which xdg-open || which gnome-open || which open) &amp;&amp; exec "$path" "$URL"
echo "Built the docs - but couldn't find a browser to open them."
</contents>
</file>
<file for="vagrant;docker;no-container">
<path>manage.py</path>
<contents>#!/usr/bin/env python3
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testapp.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)</contents>
</file>
<file for="docker"><path>Dockerfile</path>
<contents>FROM python:3.6
ENV PYTHONUNBUFFERED 1
RUN mkdir /markdownx
WORKDIR /markdownx
ADD requirements.txt /markdownx/
RUN python3.6 -m pip install -U setuptools
RUN python3.6 -m pip install -r requirements.txt
ADD . /markdownx/
RUN chmod +x /markdownx/entrypoint.sh
</contents>
</file>
<file for="docker"><path>entrypoint.sh</path>
<contents>#!/bin/sh
python manage.py migrate
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', '[email protected]', 'admin')" | python manage.py shell
exec "$@"
</contents>
</file>
<file for="docker"><path>docker-compose.yml</path>
<contents>version: '2'
services:
web:
restart: always
build: .
command: python3.6 manage.py runserver 0.0.0.0:8000
volumes:
- .:/markdownx
ports:
- "8000:8000"
mem_limit: 500m
cpuset: "1"
entrypoint: "bash entrypoint.sh"</contents>
</file>
<file for="vagrant;docker;no-container"><path>runtests.py</path>
<contents>from __future__ import absolute_import
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), 'markdownx'))
import django
from django.conf import settings
configure_settings = {
'DATABASES': {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
},
'INSTALLED_APPS': [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.staticfiles',
'markdownx',
],
'DEBUG': False,
'STATIC_URL': '/static/',
'TEMPLATES': [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(os.path.abspath(os.path.dirname(__file__)), 'markdownx/tests/templates'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
],
'debug': True,
},
},
],
'ROOT_URLCONF': 'tests.urls',
}
settings.configure(**configure_settings)
django.setup()
from django.test.utils import get_runner
test_runner = get_runner(settings)
failures = test_runner(
verbosity=1,
interactive=False,
failfast=False).run_tests(['tests'])
sys.exit(failures)</contents>
</file>
</dev>