Code Monkey home page Code Monkey logo

nimforum's Introduction

nimforum

NimForum is a light-weight forum implementation with many similarities to Discourse. It is implemented in the Nim programming language and uses SQLite for its database.

Examples in the wild

forum.nim-lang.org

forum.nim-lang.org

Features

  • Efficient, type safe and clean single-page application developed using the Karax and Jester frameworks.
  • Utilizes SQLite making set up much easier.
  • Endlessly customizable using SASS.
  • Spam blocking via new user sandboxing with great tools for moderators.
  • reStructuredText enriched by Markdown to make formatting your posts a breeze.
  • Search powered by SQLite's full-text search.
  • Context-aware replies.
  • Last visit tracking.
  • Gravatar support.
  • And much more!

Setup

See this document.

Dependencies

The following lists the dependencies which you may need to install manually in order to get NimForum running, compiled*, or tested†.

  • libsass
  • SQLite
  • pcre
  • Nim (and the Nimble package manager)*
  • geckodriver
    • Firefox†

[*] Build time dependencies

[†] Test time dependencies

Development

Check out the tasks defined by this project's nimforum.nimble file by running nimble tasks, as of writing they are:

backend              Compiles and runs the forum backend
runbackend           Runs the forum backend
frontend             Builds the necessary JS frontend (with CSS)
minify               Minifies the JS using Google's closure compiler
testdb               Creates a test DB (with admin account!)
devdb                Creates a test DB (with admin account!)
blankdb              Creates a blank DB
test                 Runs tester
fasttest             Runs tester without recompiling backend

To get up and running:

git clone https://github.com/nim-lang/nimforum
cd nimforum
git submodule update --init --recursive

# Setup the db with user: admin, pass: admin and some other users
nimble devdb

# Run this again if frontend code changes
nimble frontend

# Will start a server at localhost:5000
# MacOS users should note that port 5000 is reserved for AirPlay
# Set the entry "port" in forum.json to change the default
nimble backend

Development typically involves running nimble devdb which sets up the database for development and testing, then nimble backend which compiles and runs the forum's backend, and nimble frontend separately to build the frontend. When making changes to the frontend it should be enough to simply run nimble frontend again to rebuild. This command will also build the SASS nimforum.scss file in the public/css directory.

With docker

You can easily launch site on localhost if you have docker and docker-compose. You don't have to setup dependencies (libsass, sglite, pcre, etc...) on you host PC.

To get up and running:

cd docker
docker-compose build
docker-compose up

And you can access local NimForum site. Open http://localhost:5000 .

Troubleshooting

You might have to run nimble install karax@#5f21dcd, if setup fails with:

andinus@circinus ~/projects/forks/nimforum> nimble --verbose devdb
[...]
 Installing karax@#5f21dcd
       Tip: 24 messages have been suppressed, use --verbose to show them.
     Error: No binaries built, did you specify a valid binary name?
[...]
     Error: Exception raised during nimble script execution

The hash needs to be replaced with the one specified in output.

Copyright

Copyright (c) 2012-2018 Andreas Rumpf, Dominik Picheta.

All rights reserved.

License

NimForum is licensed under the MIT license.

nimforum's People

Contributors

andinus avatar araq avatar avsej avatar clementjnc avatar dependabot[bot] avatar digitalcraftsman avatar dom96 avatar euantorano avatar federicoceratto avatar flaviut avatar g4mr avatar gradha avatar hvnsweeting avatar jiro4989 avatar jyapayne avatar lallulli avatar leu-gim avatar markprocess avatar metagn avatar narimiran avatar nycto avatar oderwat avatar omentic avatar ringabout avatar singularperturbation avatar stisa avatar weebnetsu avatar yardanico avatar yglukhov avatar zetashift avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nimforum's Issues

Prohibitively slow postActivity.xml

time wget 'http://forum.nimrod-lang.org/postActivity.xml' -q -O/dev/null 0,00s user 0,00s system 0% cpu 39,923 total
Single-threading and 40 seconds per request means that I could DoS forum from 56kbit modem.

I think that this is caused by SQLite being unable to optimize this request:

SELECT A.id, B.name, A.content, A.thread, A.header, strftime('%Y-%m-%dT%H:%M:%SZ', A.creation), A.creation, COUNT(C.id) FROM post AS A, person AS B, post AS C WHERE A.author = B.id AND A.thread = C.thread AND C.id <= A.id GROUP BY A.id ORDER BY A.creation DESC LIMIT ?"

I think that there is nothing inherently slow in this request, but SQLite has rather primitive optimizer (compared to MsSQL/Postgres). Maybe explicit join or subqueries will be faster?

nim-lang.org not served over HTTPS

nim-lang.org is not available over HTTPS at all. Since it includes a way for people to log in it should be HTTPS-only.

Free TLS certificates are available from Let's Encrypt.

Menu at top of page different

Menu at the top of the page differes to the rest of the Nim-Lang website, which has
Learn Docs Download Support Forum FAQ

Feature request: Postgres support

I'd like to deploy a modified nimforum to a website, but I would like it to support the immutable infrastructure patterns I've been setting up my infrastructure around. Would it be possible to add support for Nimforum to connect to Posgres servers instead of just using SQLite?

Create empty title posts

A user is allowed to input any character sequence for the subject of a post, the only restriction seems to be three characters of length. By entering three spaces the post is created and can be accessed directly by its id url, but it won't show up properly in the thread list of the forums since the whitespace characters don't provide any surface for clicking.

A better validation would be to check the length of the subject after removing whitespace from front/tail of user input.

Compilation error with nimforum, Nim 0.12.1

...
ast.nim(1245)            sonsLen
system.nim(2533)         sysFatal
Error: unhandled exception: sons is not accessible [FieldError]
FAILURE: Build failed for package: nimforum

On Linux AMD64 with f3814be5305743b version of Nim

Forum sign up not possible

Sorry for cross post -- just for sake of completeness.

None of my email addresses are allowed, due to the apparent restrictions:

  • Addresses can have at most 30 characters (as a hard limit on the input box).
  • University addresses (e.g., kit.edu) are not accepted as a valid domain (results in: Error: Invalid email address).

More spam

Spammers are using the following keywords:

fifa and UK.

Check if the user is new, and disallow those.

Password reset

Would be nice if there was a way to reset the password. It already asks for email, so you could just send confirmation to that.

(I forgot my password for nim-lang.org's forum, heh.)

Show IP of user to admins

The profile view should show the user's IP address so that we can more easily determine whether the user should be banned or not.

Run-time error for searches with just an exclusion term (with a solution)

Searches like "-qwe" result in a run-time error (exception).
This due to - before a word stands for exclusion (for no such word in results) in SQLite's full-text search, and it disallows using only exclusions in a search. Though I expected just an empty result from such a search, not an exception.

Such code replacing line 1338 in forum.nim solves the problem:

    var q = @"q".strip
    if q[0]=='-' and not q.contains(Whitespace):
      q=""

If a PR's needed, I can make it, or the code can be taken from here.

*Not* security issue: Displays edit view for post regardless of ownership

Steps to reproduce:

  1. Create post
  2. Copy the link for "Edit Post"
  3. Change postid parameter in http://forum.nim-lang.org/t/<thread_number>?action=edit&postid=<new_post_ID> to a lower post.

Opens view for editing post; if you try to actually submit changes this will fail if you're not the owner (so not a security issue), but should still fail earlier (and not bring unauthorized user to edit page).

Content limits are not enforced at db level

The varchar(1000) for posts' content is not enforced, you can easily post over that limit by copying/pasting a text repeatedly. Length of both subject and content need to be checked before sql insertion.

It would be nice also if the html had some javascript which told the user about this limit as the number of left chars. An example of this behaviour can be seen on stackoverflow, where above a certain limit, the number of characters left is displayed in different colors near the text area.

Emails

Would it be possible to have an email sent to you when either:

  • Someone mentions your name via @username syntax.
  • You "track" a topic.

This would be amazing!

Feature: mailing list mirroring

Every new message on the forum could be also sent to a mailing list (possibly in a way that allows threading).
It would be awsome if people could also reply to the emails on the mailing list and nimforum coulld ingest them and replicate them in the forum (effectivly mirroring the mailing list)

  • Forum to mailing list
  • Sender/Resent-From field
  • Email threading
  • Mailing list to forum

Let users mark spam

Implement threads which are hidden because they have been marked as "spam" by many users.

Can't get it to work (after I found some stuff to fix)

When I try to compile I first get a problem because "rst" is not imported.

The cfg File seems not to work for me (obviously I do not have $nimrod defined)!

--path:"$nimrod/lib/packages/docutils"

--path:"$nimrod"

I added path="$lib/packages/docutils" to my /etc/nim.cfg and that was fixed.

I tried to do the same in forum.nim.cfg and it worked. So I guess that could be fixed in this repository. I would be happy to make a PR.

After that was done it complained about:

clang: error: no such file or directory: '/Users/hara/devsys/workspace/nim/nimforum/nimcache/crypt-blowfish.o'

I found this is because the nim bcrypt lib does not compile on OS X. I could fix that and created a pull request (runvnc/bcryptnim#2)

After those changes I can compile with nimble build and it runs. But on the website I get this error:

An error has occured in one of your routes.

Detail: no such table: thread

I thought this could be fixed by importing the fts.sql I saw in the directory. Blindly trying with sqlite3 nimforum.db < fts.sql gave an error. The file is obviously not what I thought :)

Here I can't continue? How to initialise the sql and get the Forum flying?

Random HN feedback

https://news.ycombinator.com/item?id=10935311

Ah, sorry that I assumed it was all Araq's doing. Here's my feedback:

I see no way to keep track of threads I've posted in, or threads I am interested in, or get notifications when people reply. That would be the most important thing. Maybe I'm missing something, because right now I read down the list of subjects for threads I'm interested in, and look for whether the most recent responder is different from who I remember.

Writing forum comments in ReStructuredText is not friendly. Anyone who is not wise to the ways of the forum is going to fail the first time they try to post code, and I still have to look up a ReStructuredText reference, because I never use RST for anything else. Just use GitHub-flavored Markdown, the markup language of least surprise for developers.

As another person responded, reading a thread longer than 10 messages is unnecessarily awkward. The navigation buttons -- which must be used frequently -- are not particularly prominent on a computer screen, and on a phone they're like a millimeter in diameter.

Interface elements are strange. Why is someone's username a link if the page behind it doesn't do anything useful such as list their posts? Why does the timestamp have a dotted line under it? What am I supposed to be able to do with the timestamp? I would expect from other places that it would be a permalink, but it seems to just be nothing.

Nested templates to define `/=` fails with sem

The following are 5 attempts at defining a /= operator for a simple vector compiled via

nimrod c --run test.nim

Changing ATTEMPT to 1 through 4 compiles just fine. ATTEMPT = 0 results in the compilation failure at the bottom. Summary:

  • This seems to happen when using double-nested templates.
  • The problem seems to be specific to the /= operator as +=, -=, and *= define just fine using the double-nested template.
type TVec2* {.pure, final.}[Scalar] = object
  elts: array[0..1, Scalar]

template defineOpAssign(tvec: expr, op: expr) {.immediate.} =
  proc op*(v: var tvec, w: tvec) {.inline.} =
    for i in 0..1:
      op(v.elts[i], w.elts[i])

const ATTEMPT = 0

when ATTEMPT == 0:
  # FAILS: defining `/=` with template calling template
  # ERROR about sem.nim line 144
  template defineOpAssigns(tvec: expr) {.immediate.} =
    defineOpAssign(tvec, `/=`)

  defineOpAssigns(TVec2)

when ATTEMPT == 1:
  # WORKS: defining `*=` with template calling template
  template defineOpAssigns(tvec: expr) {.immediate.} =
    defineOpAssign(tvec, `*=`)

  defineOpAssigns(TVec2)

when ATTEMPT == 2:
  # WORKS: defining `/=` calling the inner template directly
  defineOpAssign(TVec2, `/=`)

when ATTEMPT == 3:
  # WORKS: inlining inner template
  template defineOpAssigns(tvec: expr) {.immediate.} =
    proc `/=`*(v: var tvec, w: tvec) {.inline.} =
      for i in 0..1:
        `/=`(v.elts[i], w.elts[i])

  defineOpAssigns(TVec2)

when ATTEMPT == 4:
  # WORKS: defining `/=` directly
  proc `/=`*(v: var TVec2, w: TVec2) {.inline.} =
    for i in 0..1:
      `/=`(v.elts[i], w.elts[i])

The error is

Hint: system [Processing]
lib/system/ansi_c.nim(81, 12) Warning: undeclared conditional symbol; use --symbol to declare it: nimSigSetjmp [User]
lib/system/ansi_c.nim(81, 42) Warning: undeclared conditional symbol; use --symbol to declare it: nimStdSetjmp [User]
lib/system/ansi_c.nim(88, 12) Warning: undeclared conditional symbol; use --symbol to declare it: nimRawSetjmp [User]
lib/system/ansi_c.nim(88, 42) Warning: undeclared conditional symbol; use --symbol to declare it: nimStdSetjmp [User]
Hint: test [Processing]
test.nim(17, 17) Info: instantiation from here
test.nim(15, 18) Info: instantiation from here
test.nim(17, 17) Info: instantiation from here
test.nim(15, 18) Info: instantiation from here
Error: internal error: (filename: compiler/sem.nim, line: 144)
No stack traceback available

Link to first new post

It is not possible to directly jump to the first new post - one always has to open a thread at the beginning and then jump manually to the end of the posts that are already read, which is difficult to find when there are multiple new posts.

feature: flag a topic as solved

Add ability for poster (or admin) to flag the topic as solved,
and then the topic title gets prepended with the "Solved: " tag

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.