GithubHelp home page GithubHelp logo

alteras1 / discourse-awesome-bbcodes Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rux-pizza/discourse-awesome-bbcodes

0.0 0.0 0.0 247 KB

License: Other

CSS 4.35% JavaScript 93.94% Ruby 1.35% HTML 0.35%

discourse-awesome-bbcodes's Introduction

#discourse-awesome-bbcodes

A Discourse Plugin to support nestable BBCode tags spawning across multiple paragraphs in your posts. By default, support is provided for the following tags:

  • [hide=], [nsfw]
  • [color=]
  • typefaces: [humanism],[corporate],[smartass],[alpha],[rainbow]
  • [spoiler]

It also features adds auto-complete to the composer for these tags.

Compatible with Discourse v1.7.x

##Usage

By pressing [ into the composer, the auto-complete dropdown kicks in to let you choose the tag you want. BBCodes have two modes: block and inline.

  • block: puts its content in a new <div> block.
  • inline: puts the first line of its content within the current the line, and each new line in its own nestable <span> tag.

By default, hide and nsfw have block semantics. The other tags have inline semantics by default, unless a line-break is added after the opening tag:

Hey [color=red]
dude!
[/color]

If nesting multiple tags with no space in between the opening tags and a line-break after the last opening tag, all the tags will use block semantics:

Hey [humanism][color=red]
dude!
[/color][/humanism]

###Spoiler

In your posts, surround text or images with [spoiler] ... [/spoiler]. For example:

   I watched the murder mystery on TV last night. [spoiler]The butler did it[/spoiler].

For images, make sure to add a line-break after the opening tag, this activates block semantics and prevents the light-box post-processor that runs server-side to break your spoiler.

   I watched the murder mystery on TV last night. [spoiler]
   <img src="murder.jpg">
   [/spoiler].

Spoiler is an improved version over the original discourse-spoiler-alert plugin, in that it spoils links and colored text correctly, but it also spoils multiline content.

###Hide/NSFW

In your posts, surround text with [hide=some title] and [/hide] or with [nsfw] and [/nsfw]

The author explains this in great detail in section 7.
[hide=TL DR]
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam a turpis vel mi vulputate elementum in a urna. Quisque eget odio nec urna egestas luctus id sed eros. Phasellus rhoncus sagittis nibh vitae convallis. Cras nec suscipit ex, ut ullamcorper quam. Quisque maximus rutrum tellus non tempus. Vivamus non semper urna, at tristique dui. Mauris bibendum nulla eget metus tristique, nec fringilla leo ultrices. Fusce fringilla purus a luctus tincidunt. Donec mattis risus ac elit molestie lobortis. Quisque convallis risus velit, ac hendrerit quam sagittis et. Nullam et ex vel lacus volutpat iaculis.
[/hide]
[nsfw]
Great a**
http://www.example.com/sexypic.jpg
[/nsfw]

###Color

In your posts, surround text with [color=...] and [/color]. Color values are those supported by HTML, like red and #ff000. For example:

Look at my [color=red]red words[/color] and be amazed! Also, [color=#33ff33]green is cool[/color] too.

###Typefaces

In your posts, surround text with [humanism] and [/humanism].

[humanism]I hold in high regard humanity in general.[/humanism]

You can also replace humanism with smartass, corporate, rainbow, alpha for a different effect.

##Installation

  • Add the plugin's repo url to your container's yml config file
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - mkdir -p plugins
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/rux-pizza/discourse-awesome-bbcodes.git
  • Rebuild the container
cd /var/docker
git pull
./launcher rebuild app

Known issues

  • Images within spoilers do not really work unless spoiler is in block mode. To start a spoiler in block mode, simply add a line break after the opening tag:
[spoiler]
<img src="some-image.jpg>
[/spoiler]

Inside the preview, an image within a inline spoiler might appear to work at first. When posted, the spoiler will break due to the light-box postprocessing done by the server. Due to the way the plugin works at the moment, this is an issue that is hard to solve.

  • spoiler rendering might be slower than with the original spoiler-alert plugin. For now, this is because our spoiler is much more functional: it spoils links and colored text correctly, and not much optimization has been done. The performance might improve in the future.
  • At the moment, BBCodes within triple code ticks are processed as if they were regular text.

Credits

Authors: David Montoya, Charles-Pierre Astolfi

License

MIT

Full list of licenses available in LICENSE.md

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.