Blog

  • rvslides

    rvslides

    Richard Wen
    rrwen.dev@gmail.com

    Minimalistic command line tool for templating and PDF rendering of reveal.js presentations.

    npm install rvslides -g
    rvslides create
    rvslides pdf
    

    WARNING: No longer installs properly due to changes from decktape.

    Install

    1. Ensure Node.js is installed
    2. Install via npm:
    npm install rvslides -g
    

    For the latest developer version, see Developer Install.

    Usage

    Generate slides index.html in the current directory:

    rvslides create
    
    • Edit the index.html file to modify slides
    • Replace the img/logo.svg file to change the logo

    Render index.html slides as a PDF pdf/index.pdf:

    rvslides pdf
    

    For usage help, use rvslides -h

    Advanced Usage

    Render Portable Document File (PDF)

    PDF support is based on decktape.

    • Generate pdf/index.pdf for index.html with rvslides pdf
    • Generate a PDF with different html slides and output with rvslides pdf path/to/slides.html path/to/slides.pdf

    Manage JavaScript (JS) Packages

    The JS packages are contained in js/ with package management based on bower.

    • Install bower npm install bower -g
    • Install JS packages with bower install <package-name>
    • Update JS packages with bower update <package-name>
    • Uninstall JS packages with bower uninstall <package-name>

    Developer Notes

    TO DO

    • Incorporate a templating engine
    • Document Github hosting
    • Create unit tests

    Developer Install

    1. Ensure git is installed
    2. Install via git:

    git clone https://github.com/rrwen/rvslides
    cd rvslides
    npm install -g
    

    Developer Maintenance

    1. Update package and slide dependencies
    2. Check slides/index.html
    3. Commit and push changes

    npm update --save
    npm run bower update --save
    npm add .
    npm commit -a -m "Maintenance update"
    npm push
    

    Implementation Notes

    PDF Support Implementation

    PDF generation is based on decktape, which requires pre-compiled phantomjs files for different operating systems. The npm command is used to install decktape directly from the Github repository. The node command is then used to call scripts/pdf/install.js to download (via request) the pre-compiled files. The pre-compiled files are located under node_modules/decktape. The scripts/pdf files can then be used by node to run decktape with rvslides pdf.

    JS Package Management Implementation

    Client-end packages are installed and updated with bower inside bower_components. Bower is installed inside this folder to avoid an unwanted global installation, however it can be installed globally by running npm install bower -g. The bower.json file is used to specify package dependencies and node is used to run updates with npm commands (inside package.json) assigned to npm run bower update, npm bower js install, and npm run bower uninstall. These commands are for updating client-end packages on the developer side.

    CSS Implementation

    The theme is defined by Cascading Style Sheets (CSS) inside css, the original reveal.js white theme, components-font-awesome, and a logo file inside img.

    Visit original content creator repository
    https://github.com/rrwen/rvslides

  • Powershell Webserver

    Powershell Webserver

    Powershell WebServer is a module that starts a webserver (without the need for IIS). Powershell command execution, script execution, upload, download and other functions are implemented.

    Powershell WebServer is is primarily intended as an example or base for own development. No multi threading, only one client at a time!

    See Script Center version: Powershell Webserver.

    Author: Markus Scholtes

    Module version: 1.0.7 / 2024-02-03

    Script version: 1.6 / 2024-01-31

    Installation

    Install with

    Install-Module WebServer

    or download manually here

    Now also on Powershell Gallery as part of the SysAdminsFriends module, see here or install with

    Install-Module SysAdminsFriends

    Project page on github is here.

    Description

    The .Net class System.Net.HttpListener delivers a basic web service without the need to install a webserver (IIS) role. Since we can use it in C#, we can do it with powershell too (and even without pain).

    There are several examples of powershell webservers in the internet, but for me it seems they all have the same origin. Thank you, original coder, whoever you are! My impulse to write a powershell webserver was a short but very impressing example on powershell.com (that unfortunately is no longer online).

    The module WebServer implements a webserver with the following functions:

    • a powershell command execution web form
    • powershell script upload and execution (as a function)
    • download files from the server
    • upload files to the server
    • script execution and embedded code with psp files
    • make the webserver beep (to find servers in the datacenter)
    • show webserver logs
    • show server starttime and current time
    • stop the webserver
    • deliver static content based on the script’s directory if none of the commands above is requested

    The webserver responds to GET methods only except the POST upload and download functionalities (implementing this really did hurt).

    Other functions can be implemented very easily.

    If you give it a try, see remarks below by all means.

    Versions

    1.0.7 / 2024-02-03

    • parameters can be handed to PSP files per POST method too
    • added wasm extension to mime list

    1.0.6 / 2023-03-27

    • changed header encoding to Windows 1252 to prevent data loss in cjk encodings
    • fixed bug that cut file names with semicolons in it

    1.0.5 / 2022-07-31

    • Introduced PSP files (Powershell Server Pages) for embedded execution
    • Updated list of mime types

    1.0.4 / 2022-04-15

    • Logs response code
    • Scripts (.ps1, .bat and .cmd) in web directory are executed by web server

    1.0.3 / 2022-01-19

    • Load index file in base dir instead of default page when present

    1.0.2 / 2021-07-04

    • Updated list of mime types

    1.0.1 / 2021-02-21

    • Updated links since Technet Gallery shut down

    1.0.0 / 2020-06-04

    • Initial release

    Examples:

    Start webserver with binding to http://localhost:8080/:

    Start-Webserver

    Start webserver with binding to all IP addresses of the system and port 8080. Administrative rights are necessary:

    Start-Webserver "http://+:8080/"

    Screen Console

    Start powershell webserver as scheduled task as user local system every time the computer starts:

    schtasks.exe /Create /TN "Powershell Webserver" /TR "powershell -Command \"Start-Webserver http://+:8080/\"" /SC ONSTART /RU SYSTEM /RL HIGHEST /F

    You can start the webserver task manually with

    schtasks.exe /Run /TN "Powershell Webserver"

    Delete the webserver task with

    schtasks.exe /Delete /TN "Powershell Webserver"

    (Scheduled tasks are always running with low priority, so some functions might be slow)

    Screen Browser

    Embedded code

    You can embed powershell code in html files with psp files (“Powershell Server Pages”). Psp files are html files in which the switch code <% toggles to powershell code and %> toggles back to html. Parameters can be handed per GET or POST.

    Screen Browser

    Remarks

    Firewall

    You may have to configure a firewall exception to allow access to the chosen port, e.g. with:

    netsh advfirewall firewall add rule name="Powershell Webserver" dir=in action=allow protocol=TCP localport=8080

    After stopping the webserver you should remove the rule, e.g.:

    netsh advfirewall firewall delete rule name="Powershell Webserver"

    How to enable https encryption

    You can also let the Powershell Webserver deliver encrypted traffic. For a description look here.

    Security

    There is no security!!! Once started the webserver can be accessed by everyone and everyone can do on the webserver system what you can do.

    Download / Upload of large files

    There is no optimization for large file download or uploads (no chunking or similiar techniques). The transfer of large files might work, or might not.

    Visit original content creator repository https://github.com/MScholtes/WebServer