Skip to content

Conversation

@halfwit
Copy link
Member

@halfwit halfwit commented Jan 29, 2021

These additional views allow embedding of text uploads from the site. They can be used as follows:

text{upload/myhash.txt}
code{upload/myhash.txt}

Internally, the code element uses highlight.js, which is fetched on demand from cloudflare for higher locality, likeliness of cached status, and ease of maintenance.
The text block is simply a <pre><code> element, ensuring that everything is html escaped.

Before this is accepted, there is a possibility that we could add styling to the code blocks, since highlight.js facilitates that pretty trivially - we could do code{upload/myhash.txt, stackoverflow-dark} as an example.

… They can be used like, text[uploads/myhash.txt], and code[uploads/myhash.txt]
@halfwit halfwit changed the title These additional views allow embedding of text uploads from the site.… Fun feature: Allow embedded text files as either plain text or highlighted code Jan 29, 2021
@halfwit
Copy link
Member Author

halfwit commented Jan 29, 2021

The code change would look something like this:

case "code":
    $Args = explode(",", $content);
    $Code = file_get_contents($Args[0]); // will always run
    $Code = htmlspecialchars($Code);
    if ($Args[1])
        $Style = $Args[1];
    else
        $Style = "default";
    return "<link rel=\"stylesheet\" href=\"//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/$style.min.css\">
    // [...]

Which would let you do something like,
code{upload/myhash.txt,stackoverflow-dark}

It's kinda neat, again just a fun feature.

Comment on lines +525 to +526
return "<link rel=\"stylesheet\" href=\"//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/default.min.css\">
<script src=\"//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js\"></script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should be loading these dependencies via npm so we can self host them instead of using a 3rd party.

npm dependencies are currently defined here -
https://github.com/wetfish/classic/blob/master/wiki/src/package.json

and there are symlinks to the node_modules folder
https://github.com/wetfish/classic/tree/master/wiki/src/js

@itsrachelfish
Copy link
Member

This repo is now deprecated, we've moved to https://github.com/wetfish/wiki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants