stories folder and injector story
This commit is contained in:
parent
19cf455b28
commit
da2ed09c19
3 changed files with 144 additions and 6 deletions
|
@ -1,5 +1,4 @@
|
||||||
<INJECT>cat $HOME/template/header.html | sed "s/__PAGE TITLE__/Rusty's website/"</INJECT>
|
<INJECT>cat $HOME/template/header.html | sed "s/__PAGE TITLE__/Rusty's website/"</INJECT>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Folders: <INJECT>cd $CURRENT && ls */ -d | sed 's/\///' | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
Folders: <INJECT>cd $CURRENT && ls */ -d | sed 's/\///' | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
||||||
<br>
|
<br>
|
||||||
|
|
18
stories/index.html
Normal file
18
stories/index.html
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<INJECT>cat $HOME/template/header.html | sed "s/__PAGE TITLE__/Stories/"</INJECT>
|
||||||
|
|
||||||
|
<h1>Stories</h1>
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
Random stories, either about things I make(programs, games, physical stuff),
|
||||||
|
<br>
|
||||||
|
or about stuff that happens to me
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Stories:
|
||||||
|
<br>
|
||||||
|
<INJECT>cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<INJECT>cat $HOME/template/footer.html</INJECT>
|
121
stories/injector.html
Normal file
121
stories/injector.html
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
<INJECT>cat $HOME/template/header.html | sed "s/__PAGE TITLE__/Injector/"</INJECT>
|
||||||
|
<p>
|
||||||
|
Folders: <INJECT>cd $CURRENT && ls */ -d | sed 's/\///' | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
||||||
|
<br>
|
||||||
|
Files: <INJECT>cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h1>Injector</h1>
|
||||||
|
<p>
|
||||||
|
<a href = "https://gitea.rustystriker.dev/RustyStriker/command_injector">Source Code</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
So, I have finally made the html "injector" I wanted to make for ages before
|
||||||
|
I could really start working on this website...
|
||||||
|
<br><br>
|
||||||
|
I guess it ain't really an "Injector", but rather it detects a special <INJECT> tag
|
||||||
|
in html files, and replaces them in what lies between the opening and closing tag,
|
||||||
|
so something like:
|
||||||
|
<br>
|
||||||
|
<code><INJECT>echo Hello world<∖INJECT></code>
|
||||||
|
<br>
|
||||||
|
will result in the text:
|
||||||
|
<br>
|
||||||
|
<code>Hello world</code>
|
||||||
|
<br>
|
||||||
|
instead<br>
|
||||||
|
which allows me to use bash and <b>THE POWER OF UNIX TERMINAL</b>
|
||||||
|
to auto update things on my website(like a unified header, footer and such).
|
||||||
|
<br><br>
|
||||||
|
It also provides 3 env variables with useful values:
|
||||||
|
<ul>
|
||||||
|
<li>$HOME - the start directory which the injector copies files from.</li>
|
||||||
|
<li>$CURRENT - current directory the injector is copying from.</li>
|
||||||
|
and
|
||||||
|
<li>$FILE - the current file we are injecting.</li>
|
||||||
|
</ul>
|
||||||
|
This allows me to do stuff like injecting the files in the directory the current page sits in,
|
||||||
|
and, because it runs the command in bash, I also get to pipe it around,<br>
|
||||||
|
letting me tranform the output of <code>ls</code> for example, to simple <a> tags using
|
||||||
|
<a href = "https://gitea.rustystriker.dev/RustyStriker/website/src/branch/master/bscripts/ls_to_a.py">
|
||||||
|
a simple python script
|
||||||
|
</a>
|
||||||
|
<br>
|
||||||
|
and a call to python3
|
||||||
|
(the actual commands are in the top of the source code of this page for example)
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3>But, can't it leak critical information to the outside world?</h3>
|
||||||
|
<p>
|
||||||
|
I am not a security expert, but you have full control over the commands,
|
||||||
|
and they are run on the server/compiling machine during compile time
|
||||||
|
<br>
|
||||||
|
so unless you let random people push compiling web pages,
|
||||||
|
it shouldn't have any risks involved.
|
||||||
|
<br><br>
|
||||||
|
If your website is open source(like mine) or source available,
|
||||||
|
<br>
|
||||||
|
well,
|
||||||
|
<br>
|
||||||
|
you can just use commands that are in the same directory as the compiling websites
|
||||||
|
(like i keep the build scripts in the <i>bscripts</i> folder).
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3>The original plan</h3>
|
||||||
|
<p>
|
||||||
|
The original plan was different, I initially wanted a fully real time thingy,
|
||||||
|
with specific items in mind,
|
||||||
|
<br>
|
||||||
|
and only yesterday(10/6/22) I decided to just have simple commands,
|
||||||
|
<br>
|
||||||
|
which later(roughly 3 minutes after finishing the first draft)
|
||||||
|
<br>
|
||||||
|
I decided to make into a bash commands, to better have what I aimed for
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3>Rust can be annoing sometimes</h3>
|
||||||
|
<p>
|
||||||
|
Rust can be a bitch when it comes to handling strings,
|
||||||
|
especially when you compare it to C,
|
||||||
|
<br>
|
||||||
|
where every string is a byte array, and you just handle it as such...
|
||||||
|
<br><br>
|
||||||
|
Yes, I know this is due to characters not being uniform in length when using UTF-8,
|
||||||
|
<br>
|
||||||
|
and I know that C can fuck everything up if you dont watch out for multiple length bytes,
|
||||||
|
<br>
|
||||||
|
but it's just soo easy destroying strings there and you can just manipulate a string so easily,
|
||||||
|
<br>
|
||||||
|
without any extra functions or allocations or anything really...
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3>Still glad I used Rust</h3>
|
||||||
|
<p>
|
||||||
|
I'm kind of a Rust fanboy(<i>catgirl</i>),
|
||||||
|
because it lets you not worry about a lot of things,
|
||||||
|
and mostly because of it <b>STRONG</b> type system,
|
||||||
|
so it aint a surprise I used it
|
||||||
|
<br>
|
||||||
|
(and glad because of it)
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The repetuar of my languages isn't big, it's actually kinda small,
|
||||||
|
I know Rust well, I can do C quite easily(although I will need a lot of debugging),
|
||||||
|
I have a lot of experience with C#, and can do JavaScript, Java(tho not really), Python
|
||||||
|
and probably some more but very slowly.also want to rely on it less and less
|
||||||
|
<br>
|
||||||
|
<i>(i can also do GDScript if you consider it, as it can only run, afaik, in Godot)</i>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
So it is usually either using Rust, or C, since I will (<i>hopefully</i>)
|
||||||
|
wont use python for something big(more than 50 lines of code),
|
||||||
|
and C# feels locked away on linux(and I don't want to use it outside of work).
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<INJECT>cat $HOME/template/footer.html</INJECT>
|
Loading…
Reference in a new issue