From 9cf5b1f01cd67f487a22a0297142cddbb7abb48c Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 10 Nov 2019 02:45:27 -0600 Subject: [PATCH] dtext: add dtext cheatsheet popup. --- app/controllers/static_controller.rb | 6 +- app/javascript/src/styles/common/dtext.scss | 16 ++++ app/views/dtext/_form.html.erb | 2 +- app/views/static/_dtext_help.html.erb | 96 +++++++++++++++++++++ app/views/static/dtext_help.js.erb | 10 +++ config/routes.rb | 1 + 6 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 app/views/static/_dtext_help.html.erb create mode 100644 app/views/static/dtext_help.js.erb diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index dd4ee5c08..f93848024 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -9,6 +9,10 @@ class StaticController < ApplicationController def error end + def dtext_help + redirect_to wiki_page_path("help:dtext") unless request.format.js? + end + def site_map end @@ -17,5 +21,5 @@ class StaticController < ApplicationController @post_set = PostSets::Popular.new(Date.yesterday.to_s, "week", limit: 200) @posts = @post_set.posts render layout: false - end + end end diff --git a/app/javascript/src/styles/common/dtext.scss b/app/javascript/src/styles/common/dtext.scss index 8137331ba..f93cfea03 100644 --- a/app/javascript/src/styles/common/dtext.scss +++ b/app/javascript/src/styles/common/dtext.scss @@ -135,3 +135,19 @@ div.dtext-preview { margin-left: 1em; } } + +div#dtext-help { + td { + > *, div.spoiler p { + margin: 0; + } + + h1, h6 { + padding: 0; + } + } + + #dtext-help-footnote { + margin: 1em 0 0 0; + } +} diff --git a/app/views/dtext/_form.html.erb b/app/views/dtext/_form.html.erb index 9ec8894ca..8e763fadb 100644 --- a/app/views/dtext/_form.html.erb +++ b/app/views/dtext/_form.html.erb @@ -10,5 +10,5 @@ <% end %>
- All text is formatted using <%= link_to_wiki "DText", "help:dtext" %> + <%= link_to "Formatting help", dtext_help_path, remote: true, method: :get %>. diff --git a/app/views/static/_dtext_help.html.erb b/app/views/static/_dtext_help.html.erb new file mode 100644 index 000000000..d4892b910 --- /dev/null +++ b/app/views/static/_dtext_help.html.erb @@ -0,0 +1,96 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
What you typeWhat you get
[b]bold[/b]bold
[i]italics[/i]italics
[u]underline[/u]underline
[s]strikethrough[/s]strikethrough
[tn]note[/tn]<%= format_text "[tn]note[/tn]" %>
[spoilers]ssh![/spoilers]<%= format_text " [spoilers]ssh![/spoilers]" %>
<<%= root_url.chomp("/") %>><%= format_text root_url.chomp("/") %>
"<%= Danbooru.config.app_name %>":[<%= root_url.chomp("/") %>]<%= format_text "\"#{Danbooru.config.app_name}\":[#{root_url.chomp("/")}]" %>
[[Kantai Collection]]<%= format_text "[[Kantai Collection]]" %>
[[Kantai Collection|Kancolle]]<%= format_text "[[Kantai Collection|Kancolle]]" %>
[[Kaga (Kantai Collection)|]]<%= format_text "[[Kaga (Kantai Collection)|]]" %>
{{kantai_collection comic}}<%= format_text "{{kantai_collection comic}}" %>
@user<%= format_text "@user" %>
post #1<%= format_text "post #1" %>
topic #1<%= format_text "topic #1" %>
+ * one
+ * two
+ * three
+
<%= format_text "* one\n* two\n* three" %>
h1. Big header<%= format_text "h1. Big header" %>
h6. Small header<%= format_text "h6. Small header" %>
[quote]Somebody said: hi![/quote]<%= format_text "[quote]Somebody said: hi![/quote]" %>
+ +

+ See <%= link_to_wiki "help:dtext" %> for more formatting help. +

+
diff --git a/app/views/static/dtext_help.js.erb b/app/views/static/dtext_help.js.erb new file mode 100644 index 000000000..b6bdbe8e4 --- /dev/null +++ b/app/views/static/dtext_help.js.erb @@ -0,0 +1,10 @@ +$("<%= j render "static/dtext_help" %>").dialog({ + title: "DText Help", + width: 700, + modal: true, + buttons: { + "Close": function() { + $(this).dialog("close"); + } + } +}); diff --git a/config/routes.rb b/config/routes.rb index bc5d15dce..c7e6b418a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -409,6 +409,7 @@ Rails.application.routes.draw do get "/static/site_map" => "static#site_map", :as => "site_map" get "/static/terms_of_service" => "static#terms_of_service", :as => "terms_of_service" get "/static/contact" => "static#contact", :as => "contact" + get "/static/dtext_help" => "static#dtext_help", :as => "dtext_help" get "/meta_searches/tags" => "meta_searches#tags", :as => "meta_searches_tags" get "/intro" => redirect("/explore/posts/intro")