Implements /about/license
This commit is contained in:
parent
ff70dce9e8
commit
1592be0503
6 changed files with 92 additions and 42 deletions
|
|
@ -1,30 +1,30 @@
|
||||||
Forum content license
|
Content license
|
||||||
=====================
|
===============
|
||||||
|
|
||||||
All the content contributed to the Nim Forum is `cc-wiki (aka cc-by-sa)
|
All the content contributed to $hostname is `cc-wiki (aka cc-by-sa)
|
||||||
<http://creativecommons.org/licenses/by-sa/3.0/>`_ licensed, intended to be
|
<http://creativecommons.org/licenses/by-sa/3.0/>`_ licensed, intended to be
|
||||||
**shared and remixed**. In the future we may even provide all this data as a
|
**shared and remixed**.
|
||||||
convenient data dump.
|
|
||||||
|
|
||||||
But our cc-wiki licensing, while intentionally permissive, does **require
|
The cc-wiki licensing, while intentionally permissive, does require
|
||||||
attribution**::
|
attribution:
|
||||||
|
|
||||||
**Attribution** — You must attribute the work in the manner specified by
|
**Attribution** — You must attribute the work in the manner specified by
|
||||||
the author or licensor (but not in any way that suggests that they endorse
|
the author or licensor (but not in any way that suggests that they endorse
|
||||||
you or your use of the work).
|
you or your use of the work).
|
||||||
|
|
||||||
Let us clarify what we mean by attribution. If you republish this content, we
|
This means that if you republish this content, you are
|
||||||
require that you:
|
required to:
|
||||||
|
|
||||||
* **Visually indicate that the content is from the Nim Forum**. It doesn’t
|
* **Visually indicate that the content is from the $name**. It doesn’t
|
||||||
have to be obnoxious; a discreet text blurb is fine.
|
have to be obnoxious; a discreet text blurb is fine.
|
||||||
* **Hyperlink directly to the original post** (e.g.,
|
* **Hyperlink directly to the original post** (e.g.,
|
||||||
http://forum.nim-lang.org/t/186)
|
https://$hostname/t/186/1#908)
|
||||||
* **Show the author names** for every post.
|
* **Show the author names** for every post.
|
||||||
* **Hyperlink each author name** directly back to their user profile page
|
* **Hyperlink each author name** directly back to their user profile page
|
||||||
(e.g., http://forum.nim-lang.org/profile/Araq)
|
(e.g., http://$hostname/profile/Araq)
|
||||||
|
|
||||||
By “directly”, we mean each hyperlink must point directly to our domain in
|
To be more specific, each hyperlink must
|
||||||
|
point directly to the $hostname domain in
|
||||||
standard HTML visible even with JavaScript disabled, and not use a tinyurl or
|
standard HTML visible even with JavaScript disabled, and not use a tinyurl or
|
||||||
any other form of obfuscation or redirection. Furthermore, the links must not
|
any other form of obfuscation or redirection. Furthermore, the links must not
|
||||||
be `nofollowed
|
be `nofollowed
|
||||||
|
|
@ -36,7 +36,3 @@ time to create that content in the first place!
|
||||||
|
|
||||||
Feel free to remix and reuse to your heart’s content, as long as a good faith
|
Feel free to remix and reuse to your heart’s content, as long as a good faith
|
||||||
effort is made to attribute the content!
|
effort is made to attribute the content!
|
||||||
|
|
||||||
Content previous to the forum license change of
|
|
||||||
http://forum.nim-lang.org/t/186 remains under the original authors'
|
|
||||||
copyright, and therefore you cannot reuse it.
|
|
||||||
|
|
|
||||||
|
|
@ -1848,6 +1848,15 @@ routes:
|
||||||
get "/404":
|
get "/404":
|
||||||
resp Http404, readFile("public/karax.html")
|
resp Http404, readFile("public/karax.html")
|
||||||
|
|
||||||
|
get "/about/license.html":
|
||||||
|
let content = readFile("public/license.rst").multiReplace(
|
||||||
|
{
|
||||||
|
"$hostname": config.hostname,
|
||||||
|
"$name": config.name
|
||||||
|
}
|
||||||
|
)
|
||||||
|
resp content.rstToHtml()
|
||||||
|
|
||||||
get re"/(.+)?":
|
get re"/(.+)?":
|
||||||
resp readFile("public/karax.html")
|
resp readFile("public/karax.html")
|
||||||
|
|
||||||
|
|
@ -1992,11 +2001,6 @@ routes:
|
||||||
else:
|
else:
|
||||||
resp genMain(c, genFormResetPassword(c), "Reset Password - Nim Forum")
|
resp genMain(c, genFormResetPassword(c), "Reset Password - Nim Forum")
|
||||||
|
|
||||||
get "/license":
|
|
||||||
createTFD()
|
|
||||||
resp genMain(c, rstToHtml(readFile("static/license.rst")),
|
|
||||||
"Content license - Nim Forum")
|
|
||||||
|
|
||||||
post "/search/?@page?":
|
post "/search/?@page?":
|
||||||
cond isFTSAvailable
|
cond isFTSAvailable
|
||||||
createTFD()
|
createTFD()
|
||||||
|
|
|
||||||
44
src/frontend/about.nim
Normal file
44
src/frontend/about.nim
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
when defined(js):
|
||||||
|
import sugar, httpcore, options, json
|
||||||
|
import dom except Event
|
||||||
|
|
||||||
|
include karax/prelude
|
||||||
|
import karax / [kajax, kdom]
|
||||||
|
|
||||||
|
import error, replybox, threadlist, post
|
||||||
|
import karaxutils
|
||||||
|
|
||||||
|
type
|
||||||
|
About* = ref object
|
||||||
|
loading: bool
|
||||||
|
status: HttpCode
|
||||||
|
content: kstring
|
||||||
|
page: string
|
||||||
|
|
||||||
|
proc newAbout*(): About =
|
||||||
|
About(
|
||||||
|
status: Http200
|
||||||
|
)
|
||||||
|
|
||||||
|
proc onContent(status: int, response: kstring, state: About) =
|
||||||
|
state.status = status.HttpCode
|
||||||
|
state.content = response
|
||||||
|
|
||||||
|
proc render*(state: About, page: string): VNode =
|
||||||
|
if state.status != Http200:
|
||||||
|
return renderError($state.content, state.status)
|
||||||
|
|
||||||
|
if page != state.page:
|
||||||
|
if not state.loading:
|
||||||
|
state.page = page
|
||||||
|
state.loading = true
|
||||||
|
state.status = Http200
|
||||||
|
let uri = makeUri("/about/" & page & ".html")
|
||||||
|
ajaxGet(uri, @[], (s: int, r: kstring) => onContent(s, r, state))
|
||||||
|
|
||||||
|
return buildHtml(tdiv(class="loading"))
|
||||||
|
|
||||||
|
result = buildHtml():
|
||||||
|
section(class="container grid-xl"):
|
||||||
|
tdiv(id="about"):
|
||||||
|
verbatim(state.content)
|
||||||
|
|
@ -4,7 +4,7 @@ from dom import window, Location
|
||||||
include karax/prelude
|
include karax/prelude
|
||||||
import jester/patterns
|
import jester/patterns
|
||||||
|
|
||||||
import threadlist, postlist, header, profile, newthread, error
|
import threadlist, postlist, header, profile, newthread, error, about
|
||||||
import karaxutils
|
import karaxutils
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -12,6 +12,7 @@ type
|
||||||
url: Location
|
url: Location
|
||||||
profile: ProfileState
|
profile: ProfileState
|
||||||
newThread: NewThread
|
newThread: NewThread
|
||||||
|
about: About
|
||||||
|
|
||||||
proc copyLocation(loc: Location): Location =
|
proc copyLocation(loc: Location): Location =
|
||||||
# TODO: It sucks that I had to do this. We need a nice way to deep copy in JS.
|
# TODO: It sucks that I had to do this. We need a nice way to deep copy in JS.
|
||||||
|
|
@ -30,7 +31,8 @@ proc newState(): State =
|
||||||
State(
|
State(
|
||||||
url: copyLocation(window.location),
|
url: copyLocation(window.location),
|
||||||
profile: newProfileState(),
|
profile: newProfileState(),
|
||||||
newThread: newNewThread()
|
newThread: newNewThread(),
|
||||||
|
about: newAbout()
|
||||||
)
|
)
|
||||||
|
|
||||||
var state = newState()
|
var state = newState()
|
||||||
|
|
@ -87,6 +89,9 @@ proc render(): VNode =
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
r("/about/?@page?",
|
||||||
|
(params: Params) => (render(state.about, params["page"]))
|
||||||
|
),
|
||||||
r("/404",
|
r("/404",
|
||||||
(params: Params) => render404()
|
(params: Params) => render404()
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,7 @@ when isMainModule:
|
||||||
echo("Initialising nimforum for development...")
|
echo("Initialising nimforum for development...")
|
||||||
initialiseConfig(
|
initialiseConfig(
|
||||||
"Development Forum",
|
"Development Forum",
|
||||||
"localhost.local",
|
"localhost",
|
||||||
recaptcha=("", ""),
|
recaptcha=("", ""),
|
||||||
smtp=("", "", ""),
|
smtp=("", "", ""),
|
||||||
isDev=true,
|
isDev=true,
|
||||||
|
|
@ -251,7 +251,7 @@ when isMainModule:
|
||||||
echo("Initialising nimforum for testing...")
|
echo("Initialising nimforum for testing...")
|
||||||
initialiseConfig(
|
initialiseConfig(
|
||||||
"Test Forum",
|
"Test Forum",
|
||||||
"localhost.local",
|
"localhost",
|
||||||
recaptcha=("", ""),
|
recaptcha=("", ""),
|
||||||
smtp=("", "", ""),
|
smtp=("", "", ""),
|
||||||
isDev=true,
|
isDev=true,
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ type
|
||||||
recaptchaSiteKey*: string
|
recaptchaSiteKey*: string
|
||||||
isDev*: bool
|
isDev*: bool
|
||||||
dbPath*: string
|
dbPath*: string
|
||||||
|
hostname*: string
|
||||||
|
name*: string
|
||||||
|
|
||||||
var docConfig: StringTableRef
|
var docConfig: StringTableRef
|
||||||
|
|
||||||
|
|
@ -36,19 +38,18 @@ docConfig["doc.listing_end"] = "</code><div class='code-buttons'><button class='
|
||||||
proc loadConfig*(filename = getCurrentDir() / "forum.json"): Config =
|
proc loadConfig*(filename = getCurrentDir() / "forum.json"): Config =
|
||||||
result = Config(smtpAddress: "", smtpPort: 25, smtpUser: "",
|
result = Config(smtpAddress: "", smtpPort: 25, smtpUser: "",
|
||||||
smtpPassword: "", mlistAddress: "")
|
smtpPassword: "", mlistAddress: "")
|
||||||
try:
|
let root = parseFile(filename)
|
||||||
let root = parseFile(filename)
|
result.smtpAddress = root{"smtpAddress"}.getStr("")
|
||||||
result.smtpAddress = root{"smtpAddress"}.getStr("")
|
result.smtpPort = root{"smtpPort"}.getNum(25).int
|
||||||
result.smtpPort = root{"smtpPort"}.getNum(25).int
|
result.smtpUser = root{"smtpUser"}.getStr("")
|
||||||
result.smtpUser = root{"smtpUser"}.getStr("")
|
result.smtpPassword = root{"smtpPassword"}.getStr("")
|
||||||
result.smtpPassword = root{"smtpPassword"}.getStr("")
|
result.mlistAddress = root{"mlistAddress"}.getStr("")
|
||||||
result.mlistAddress = root{"mlistAddress"}.getStr("")
|
result.recaptchaSecretKey = root{"recaptchaSecretKey"}.getStr("")
|
||||||
result.recaptchaSecretKey = root{"recaptchaSecretKey"}.getStr("")
|
result.recaptchaSiteKey = root{"recaptchaSiteKey"}.getStr("")
|
||||||
result.recaptchaSiteKey = root{"recaptchaSiteKey"}.getStr("")
|
result.isDev = root{"isDev"}.getBool()
|
||||||
result.isDev = root{"isDev"}.getBool()
|
result.dbPath = root{"dbPath"}.getStr("nimforum.db")
|
||||||
result.dbPath = root{"dbPath"}.getStr("nimforum.db")
|
result.hostname = root["hostname"].getStr()
|
||||||
except:
|
result.name = root["name"].getStr()
|
||||||
echo("[WARNING] Couldn't read config file: ", filename)
|
|
||||||
|
|
||||||
proc processGT(n: XmlNode, tag: string): (int, XmlNode, string) =
|
proc processGT(n: XmlNode, tag: string): (int, XmlNode, string) =
|
||||||
result = (0, newElement(tag), tag)
|
result = (0, newElement(tag), tag)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue