You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2018/01/31 13:48:47 UTC
[1/2] celix-site git commit: beta version of new importer,
no dir support and might not get all files
Repository: celix-site
Updated Branches:
refs/heads/asf-site dc8b8ff18 -> 38b596b67
beta version of new importer, no dir support and might not get all files
Project: http://git-wip-us.apache.org/repos/asf/celix-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix-site/commit/a47f4d7c
Tree: http://git-wip-us.apache.org/repos/asf/celix-site/tree/a47f4d7c
Diff: http://git-wip-us.apache.org/repos/asf/celix-site/diff/a47f4d7c
Branch: refs/heads/asf-site
Commit: a47f4d7c68f8435c4f48ff3bc45fe9a02a3f554a
Parents: e8ec1bc
Author: ESmink <ed...@nl.thalesgroup.com>
Authored: Mon Jan 29 12:20:47 2018 +0100
Committer: ESmink <ed...@nl.thalesgroup.com>
Committed: Mon Jan 29 12:20:47 2018 +0100
----------------------------------------------------------------------
build.py | 76 ++++++++++++++++++++++++++-----------
src/noprocess/import/style.css | 6 +--
2 files changed, 55 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix-site/blob/a47f4d7c/build.py
----------------------------------------------------------------------
diff --git a/build.py b/build.py
index 9d6bbd7..13f5f53 100755
--- a/build.py
+++ b/build.py
@@ -44,6 +44,15 @@ def combinePaths(one, two):
for x in two[i:]: segment += x + '/'
return segment[:-1]
+# tries removing all the ../ in a path
+def normalizePath(path):
+ path = path.split('/')
+ answer = ""
+ for x in path:
+ if(x == '..'):answer = answer[0:answer.rfind('/')]
+ else:answer += '/' + x
+ return answer[1:len(answer)]
+
#copy to out
if os.path.exists(out):
shutil.rmtree(out)
@@ -68,34 +77,56 @@ docT = docT.replace('/index.html', '/') + '\n</table>\n'
#register site markdown
md = ''
for f in os.listdir(markdown):
- md += '<file name="' + f[:-3] +'"><path>' + markdown + '/' + f + '</path><dest>site/' + f[:-3].replace(' ', '_') + '.html</dest></file>'
+ md += '<file><path>' + markdown + '/' + f + '</path><dest>site/' + f[:-3].replace(' ', '_') + '.html</dest></file>'
root.append(ET.fromstring('<markdown>' + md + '</markdown>'))
+root.append(ET.fromstring('<importurl></importurl>'))
+
+imported = []
+for title in root:
+ for fl in title:
+ imported.append(fl.find('path').text)
# write documents
for title in root:
- if(title.tag != 'markdown'):
- os.makedirs(out + '/doc/' + title.attrib['name'])
for fl in title:
- with open(fl.find('path').text) as f:
- file = f.read()
+ try:os.makedirs(fl.find('dest').text[0:fl.find('dest').text.rfind('/')])
+ except: IOError
+ with open(fl.find('path').text) as f:file = f.read()
o = open(fl.find('dest').text, 'w')
- # import images
+ # import url
i = 0
- while True:
- i = file.find('\n![', i)
- if(i == -1):break
- i2 = file.find('(', i)
- if(i2 == -1):break
- i3 = file.find(')', i)
- if(i3 == -1):break
- if(i2 > i3 or i3 > file.find('\n', i + 3)):
- i += 3
- continue
- # copy images here
- with open(fl.find('path').text[:fl.find('path').text.rfind('/') + 1] + file[i2 + 1:i3]) as src:
- with open(fl.find('dest').text[:fl.find('dest').text.rfind('/') + 1] + file[i2 + 1:i3], 'w') as dest:dest.write(src.read())
- i += 3
+ if(fl.find('dest').text.startswith('site/doc/')):
+ while True:
+ i = file.find('[', i)
+ if(i == -1):break
+ i2 = file.find('(', i)
+ if(i2 == -1):break
+ i3 = file.find(')', i2)
+ if(i3 == -1):break
+ if(file.find('\n', i, i3) != -1 or file.startswith('(http', i2)):
+ i += 3
+ continue
+
+ url = normalizePath(fl.find('path').text[fl.find('path').text.find('/'):fl.find('path').text.rfind('/') + 1] + file[i2 + 1:i3])
+ if('celix' + url not in imported):
+ imported.append('celix' + url)
+ # found new url
+ try:
+ with open('celix' + url) as src:
+ # add url to markdown processing
+ if(url[-3:len(url)] == '.md'):
+ root.find('importurl').append(ET.fromstring('<file><path>celix' + url + '</path><dest>site/doc/noIndex' + url[0:-3] + '.html</dest></file>'))
+ file = file[0:i2 + 1] + '/doc/noIndex' + url[0:-3] + '.html' + file[i3:len(file)]
+ # add url to files
+ else:
+ try:os.makedirs('site/doc/noIndex' + url[0:url.rfind('/')])
+ except: IOError
+ with open('site/doc/noIndex' + url, 'w') as dest:dest.write(src.read())
+ file = file[0:i2 + 1] + '/doc/noIndex' + url + file[i3:len(file)]
+ except IOError:
+ print('ERROR: could not find file: "celix' + url + '" referenced in file: ' + fl.find('path').text)
+ i = i3
# import other files
if fl.find('url'):
@@ -111,8 +142,7 @@ for title in root:
f2.close()
i = i2 + 2
- # correct markdown links
- for fl2 in root.findall('./title/file'):
+ # correct markdown links
file = file.replace(combinePaths(fl.find('path').text,fl2.find('path').text), combinePaths(fl.find('dest').text, fl2.find('dest').text))
# convert markdown to html, also add top and bottom html files
@@ -122,7 +152,7 @@ for title in root:
with open(snippets + '/top.html') as top:
file = top.read() + file
with open(snippets + '/bottom.html') as bottom:
- file = file.encode() + bottom.read()
+ file = file.encode('utf8') + bottom.read()
o.write(file)
o.close()
http://git-wip-us.apache.org/repos/asf/celix-site/blob/a47f4d7c/src/noprocess/import/style.css
----------------------------------------------------------------------
diff --git a/src/noprocess/import/style.css b/src/noprocess/import/style.css
index 82101da..44455d4 100755
--- a/src/noprocess/import/style.css
+++ b/src/noprocess/import/style.css
@@ -284,7 +284,7 @@ iframe {
}
}
-@media screen and (max-width: 965px) {
+@media screen and (max-width: 970px) {
body, #footer {
font-size: 12px;
}
@@ -352,10 +352,8 @@ iframe {
}
}
-@media screen and (max-width: 400px) {
+@media screen and (max-width: 450px) {
#docTable {
- margin-left: auto;
- margin-right: auto;
position: relative;
float: none;
}
[2/2] celix-site git commit: Merge branch 'asf-site' of
https://github.com/ESmink/celix-site into asf-site
Posted by pn...@apache.org.
Merge branch 'asf-site' of https://github.com/ESmink/celix-site into asf-site
Project: http://git-wip-us.apache.org/repos/asf/celix-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix-site/commit/38b596b6
Tree: http://git-wip-us.apache.org/repos/asf/celix-site/tree/38b596b6
Diff: http://git-wip-us.apache.org/repos/asf/celix-site/diff/38b596b6
Branch: refs/heads/asf-site
Commit: 38b596b67c81c17ab8e41c7afd322cb9a0c958c8
Parents: dc8b8ff a47f4d7
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Wed Jan 31 14:48:16 2018 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Wed Jan 31 14:48:16 2018 +0100
----------------------------------------------------------------------
build.py | 76 ++++++++++++++++++++++++++-----------
src/noprocess/import/style.css | 6 +--
2 files changed, 55 insertions(+), 27 deletions(-)
----------------------------------------------------------------------