Merge branch 'globFile' into develop
This commit is contained in:
commit
655b990601
19
ASCIIsite.py
19
ASCIIsite.py
|
@ -11,8 +11,9 @@ def parse_arguments():
|
||||||
parser=argparse.ArgumentParser(description='create a website directory structure by converting .adoc files in a directory strucutre to .html files.')
|
parser=argparse.ArgumentParser(description='create a website directory structure by converting .adoc files in a directory strucutre to .html files.')
|
||||||
parser.add_argument('inputDir', type=Path, help='The directory of adoc files to be copied and converted.')
|
parser.add_argument('inputDir', type=Path, help='The directory of adoc files to be copied and converted.')
|
||||||
parser.add_argument('-o', '--output', type=Path, help='What to name the generated directory or tar file')
|
parser.add_argument('-o', '--output', type=Path, help='What to name the generated directory or tar file')
|
||||||
parser.add_argument('-z', '--compress', action='store_true', help='whether to compress the resulting directory to a tar.gz file. can be usefull for scripting to transfer the site to a remote server.')
|
parser.add_argument('--exclude-file', type=Path, help='A text file containing glob patterns to exclude, 1 per line.')
|
||||||
parser.add_argument('--exclude', nargs='+', help='A list of glob patterns to ignore. Remember to quote them so your shell doesnt escape them!')
|
parser.add_argument('--exclude', nargs='+', help='A list of glob patterns to ignore. Remember to quote them so your shell doesnt escape them!')
|
||||||
|
parser.add_argument('-z', '--compress', action='store_true', help='whether to compress the resulting directory to a tar.gz file. can be usefull for scripting to transfer the site to a remote server.')
|
||||||
args=parser.parse_args()
|
args=parser.parse_args()
|
||||||
|
|
||||||
#set compress flag
|
#set compress flag
|
||||||
|
@ -44,7 +45,21 @@ def parse_arguments():
|
||||||
logging.info(f'outputting to {outFile.resolve()}')
|
logging.info(f'outputting to {outFile.resolve()}')
|
||||||
logging.debug(f'compress is {compress}')
|
logging.debug(f'compress is {compress}')
|
||||||
|
|
||||||
return args.inputDir.resolve(), outFile, compress, args.exclude
|
try:
|
||||||
|
with open(args.exclude_file, 'r') as file:
|
||||||
|
exclude=[glob.strip() for glob in file]
|
||||||
|
|
||||||
|
if args.exclude != None:
|
||||||
|
exclude.extend(args.exclude)
|
||||||
|
except Exception as e:
|
||||||
|
print(str(e))
|
||||||
|
exit()
|
||||||
|
|
||||||
|
if args.inputDir.resolve().exists():
|
||||||
|
print(f'Inputdir {args.inputDir.resolve()} does not exist!')
|
||||||
|
exit()
|
||||||
|
|
||||||
|
return args.inputDir.resolve(), outFile, compress, exclude
|
||||||
|
|
||||||
#Doing it in a tmpDir first, as some distrubutions put temp files on a ramdisk. this should speed up the operation sigificantly.
|
#Doing it in a tmpDir first, as some distrubutions put temp files on a ramdisk. this should speed up the operation sigificantly.
|
||||||
class TmpDir:
|
class TmpDir:
|
||||||
|
|
12
README.md
12
README.md
|
@ -11,13 +11,17 @@ ASCIISite takes 2 (so far) optional arguments followed by the single mandatory a
|
||||||
|
|
||||||
the -o or --output option simply tells ASCIISite what to name the output file.
|
the -o or --output option simply tells ASCIISite what to name the output file.
|
||||||
|
|
||||||
the --exclude flag allows you to specify a list of glob patterns. Any file matching these glob patterns will not be copied to the output.
|
|
||||||
This is helpful for any files that are needed for the compilation of the asciidoc files, but do not need to be in the final site.
|
|
||||||
The main use case I am aware of is files that are put into an asciidoc document via an include statement.
|
|
||||||
|
|
||||||
the -z or --compress flag tells ASCIISite to put the final product in a compressed tar.gz file as its output.
|
the -z or --compress flag tells ASCIISite to put the final product in a compressed tar.gz file as its output.
|
||||||
This is especially useful if you are running ASCIISite on your personal computer, and will be uploading the tar.gz file to your server.
|
This is especially useful if you are running ASCIISite on your personal computer, and will be uploading the tar.gz file to your server.
|
||||||
|
|
||||||
|
the --exclude flag allows you to specify a list of glob patterns. Any file matching these glob patterns will not be copied to the output.
|
||||||
|
|
||||||
|
The --exclude-file flag allows you to specify a file containing one glob to exclude per line. Other than inputting from a file, works exactly the same as --exclude. Note that it cannot parse the full spec of .gitignore files, only traditional globs.
|
||||||
|
|
||||||
|
Exclusions are helpful for any files that are needed for the compilation of the asciidoc files, but do not need to be in the final site.
|
||||||
|
The main use case I am aware of is files that are put into an asciidoc document via an include statement.
|
||||||
|
|
||||||
|
|
||||||
As for how to format the input directory, thats up to you. The directory structure of the input will be mirrored in the structure of the output website.
|
As for how to format the input directory, thats up to you. The directory structure of the input will be mirrored in the structure of the output website.
|
||||||
The only real rule you need to follow is that all your links to other pages in the input directory should be relative, so they dont get broken when you move the output directory around.
|
The only real rule you need to follow is that all your links to other pages in the input directory should be relative, so they dont get broken when you move the output directory around.
|
||||||
|
|
||||||
|
|
1
tests/globignore
Normal file
1
tests/globignore
Normal file
|
@ -0,0 +1 @@
|
||||||
|
include*
|
65
tests/result/include/include.txt
Normal file
65
tests/result/include/include.txt
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
== included section
|
||||||
|
|
||||||
|
Fusce maximus nec magna eu ultricies.
|
||||||
|
Fusce quis tellus vitae arcu facilisis lobortis.
|
||||||
|
Donec id erat at enim porta placerat in vitae sapien.
|
||||||
|
Duis justo arcu, hendrerit nec nulla eu, dictum dapibus ipsum.
|
||||||
|
Sed fermentum id elit eget fringilla.
|
||||||
|
Suspendisse volutpat imperdiet justo, ut efficitur odio maximus et.
|
||||||
|
Nunc interdum sollicitudin eros sit amet convallis.
|
||||||
|
Praesent volutpat tempus metus id tincidunt.
|
||||||
|
Proin aliquet justo a fermentum consectetur.
|
||||||
|
Nunc scelerisque, nisi id scelerisque dictum, nibh lectus ultrices nunc, quis ultricies erat velit sit amet urna.
|
||||||
|
Maecenas orci felis, volutpat at bibendum ut, mattis eu justo.
|
||||||
|
|
||||||
|
=== blocks
|
||||||
|
|
||||||
|
.listing block
|
||||||
|
----
|
||||||
|
example of _listing block_
|
||||||
|
with verbatim line break
|
||||||
|
----
|
||||||
|
|
||||||
|
.example block
|
||||||
|
====
|
||||||
|
example block
|
||||||
|
with line break
|
||||||
|
====
|
||||||
|
|
||||||
|
.literal block
|
||||||
|
....
|
||||||
|
_literal_ block
|
||||||
|
with line break
|
||||||
|
....
|
||||||
|
|
||||||
|
.pass block
|
||||||
|
++++
|
||||||
|
pass block
|
||||||
|
with <u>underlined text</u>
|
||||||
|
++++
|
||||||
|
|
||||||
|
.quote block
|
||||||
|
____
|
||||||
|
quote block
|
||||||
|
with line break
|
||||||
|
____
|
||||||
|
|
||||||
|
.sidebar block
|
||||||
|
****
|
||||||
|
sidebar block
|
||||||
|
with line break
|
||||||
|
****
|
||||||
|
|
||||||
|
[NOTE]
|
||||||
|
====
|
||||||
|
This is an example of an admonition block.
|
||||||
|
|
||||||
|
Unlike an admonition paragraph, it may contain any AsciiDoc content.
|
||||||
|
The style can be any one of the admonition labels:
|
||||||
|
|
||||||
|
* NOTE
|
||||||
|
* TIP
|
||||||
|
* WARNING
|
||||||
|
* CAUTION
|
||||||
|
* IMPORTANT
|
||||||
|
====
|
Loading…
Reference in a new issue