diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index fde1b09..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,80 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: CI - -# Controls when the action will run. -on: - # Triggers the workflow on push or pull request events but only for the master branch - push: - branches: [ master ] - pull_request: - branches: [ master ] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - test_stable: - runs-on: ubuntu-latest - strategy: - matrix: - firefox: [ '73.0' ] - include: - - nim-version: 'stable' - cache-key: 'stable' - steps: - - uses: actions/checkout@v2 - - name: Checkout submodules - run: git submodule update --init --recursive - - - name: Setup firefox - uses: browser-actions/setup-firefox@latest - with: - firefox-version: ${{ matrix.firefox }} - - - name: Get Date - id: get-date - run: echo "::set-output name=date::$(date "+%Y-%m-%d")" - shell: bash - - - name: Cache choosenim - uses: actions/cache@v2 - with: - path: ~/.choosenim - key: ${{ runner.os }}-choosenim-${{ matrix.cache-key }} - - - name: Cache nimble - uses: actions/cache@v2 - with: - path: ~/.nimble - key: ${{ runner.os }}-nimble-${{ hashFiles('*.nimble') }} - - - uses: jiro4989/setup-nim-action@v1 - with: - nim-version: "${{ matrix.nim-version }}" - - - name: Install geckodriver - run: | - sudo apt-get -qq update - sudo apt-get install autoconf libtool libsass-dev - - wget https://github.com/mozilla/geckodriver/releases/download/v0.29.1/geckodriver-v0.29.1-linux64.tar.gz - mkdir geckodriver - tar -xzf geckodriver-v0.29.1-linux64.tar.gz -C geckodriver - export PATH=$PATH:$PWD/geckodriver - - - name: Install choosenim - run: | - export CHOOSENIM_CHOOSE_VERSION="stable" - curl https://nim-lang.org/choosenim/init.sh -sSf > init.sh - sh init.sh -y - export PATH=$HOME/.nimble/bin:$PATH - nimble refresh -y - - - name: Run tests - run: | - export MOZ_HEADLESS=1 - nimble -y install - nimble -y test - diff --git a/.gitignore b/.gitignore index fe26a8a..83421ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # Wildcard patterns. *.swp nimcache/ -*.db* +*.db # Specific paths /createdb @@ -12,12 +12,3 @@ nimcache/ forum createdb editdb - -.vscode -forum.json* -browsertester -setup_nimforum -buildcss -nimforum.css - -/src/frontend/forum.js diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b80127e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,44 @@ +os: + - linux + +language: c + +cache: + directories: + - "$HOME/.nimble" + - "$HOME/.choosenim" + +addons: + firefox: "60.0.1" + +before_install: + - sudo apt-get -qq update + - sudo apt-get install autoconf libtool + - git clone -b 3.5.4 https://github.com/sass/libsass.git + - cd libsass + - autoreconf --force --install + - | + ./configure \ + --disable-tests \ + --disable-static \ + --enable-shared \ + --prefix=/usr + - sudo make -j5 install + - cd .. + + - wget https://github.com/mozilla/geckodriver/releases/download/v0.20.1/geckodriver-v0.20.1-linux64.tar.gz + - mkdir geckodriver + - tar -xzf geckodriver-v0.20.1-linux64.tar.gz -C geckodriver + - export PATH=$PATH:$PWD/geckodriver + +install: + - export CHOOSENIM_CHOOSE_VERSION="#987bf13" + - | + curl https://nim-lang.org/choosenim/init.sh -sSf > init.sh + sh init.sh -y + - export PATH=$HOME/.nimble/bin:$PATH + - nimble refresh -y + +script: + - export MOZ_HEADLESS=1 + - nimble -y test \ No newline at end of file diff --git a/README.md b/README.md index d7dedb4..b0ee351 100644 --- a/README.md +++ b/README.md @@ -1,131 +1,67 @@ # nimforum -NimForum is a light-weight forum implementation -with many similarities to Discourse. It is implemented in -the [Nim](https://nim-lang.org) programming -language and uses SQLite for its database. +This is Nim's forum. Available at http://forum.nim-lang.org. -## Examples in the wild +## Building -[](https://forum.nim-lang.org) +You can use ``nimble`` (available [here](https://github.com/nim-lang/nimble)) +to get all the necessary +[dependencies](https://github.com/nim-lang/nimforum/blob/master/nimforum.nimble#L11). -
+Clone this repo and execute ``nimble build`` in this repositories directory. -## Features - -* Efficient, type safe and clean **single-page application** developed using the - [Karax](https://github.com/pragmagic/karax) and - [Jester](https://github.com/dom96/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.](https://github.com/nim-lang/nimforum/blob/master/setup.md) +See also: Running the forum for how to create the database. ## Dependencies -The following lists the dependencies which you may need to install manually -in order to get NimForum running, compiled*, or tested†. +The code depends on the RST parser of the Nim compiler and on Jester. +The captchas for registration uses the [reCaptcha module](https://github.com/euantorano/recaptcha.nim). -* libsass -* SQLite -* pcre -* Nim (and the Nimble package manager)* -* [geckodriver](https://github.com/mozilla/geckodriver)† - * Firefox† +#### bcrypt -[*] 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: +On macosx you also need to make sure to use the bcrypt >= 0.2.1 module if that +is not yet updated you can install it with: ``` -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 +nimble install https://github.com/oderwat/bcryptnim.git@#fix-osx ``` -To get up and running: - -```bash -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 -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: - -```bash -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: +You may also need to change `nimforum.nimble` such that it uses 0.2.1 by +changing the dependencies slightly. ``` -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 +[Deps] +Requires: "nim >= 0.14.0, jester#head, bcrypt >= 0.2.1, recaptcha >= 1.0.0" ``` -The hash needs to be replaced with the one specified in output. +# Running the forum + +**Important: You need to compile and run `createdb` to generate the initial database +before you can run `forum` the first time**! + +**Note: If you do not have a mail server set up locally, you can specify +``-d:dev`` during compilation to prevent nimforum from attempting to send +emails and to automatically activate user accounts** + +This is as simple as: + +``` +nim c -r createdb +``` + +After that you can just run `forum` and if everything is ok you will get the info which URL you need to open in your browser (http://localhost:5000) to access it. + +_There is an update helper `editdb` which you can safely ignore for now._ + +_The file `cache.nim` is included by `forum.nim` and do +not need to be compiled by you._ # Copyright -Copyright (c) 2012-2018 Andreas Rumpf, Dominik Picheta. +Copyright (c) 2012-2017 Andreas Rumpf, Dominik Picheta. All rights reserved. # License -NimForum is licensed under the MIT license. +Nimforum is licensed under the MIT license. diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index cb3191a..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM nimlang/nim:1.2.6-ubuntu - -RUN apt-get update -yqq \ - && apt-get install -y --no-install-recommends \ - libsass-dev \ - sqlite3 \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /app -COPY . /app - -# install dependencies -RUN nimble install -Y diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml deleted file mode 100644 index 8657235..0000000 --- a/docker/docker-compose.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: "3.7" - -services: - forum: - build: - context: ../ - dockerfile: ./docker/Dockerfile - volumes: - - "../:/app" - ports: - - "5000:5000" - entrypoint: "/app/docker/entrypoint.sh" diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh deleted file mode 100755 index d8f5923..0000000 --- a/docker/entrypoint.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -set -eu - -git submodule update --init --recursive - -# setup -nimble c -d:release src/setup_nimforum.nim -./src/setup_nimforum --dev - -# build frontend -nimble c -r src/buildcss -nimble js -d:release src/frontend/forum.nim -mkdir -p public/js -cp src/frontend/forum.js public/js/forum.js - -# build backend -nimble c src/forum.nim -./src/forum diff --git a/forum.json.example b/forum.json.example new file mode 100644 index 0000000..8cf9e86 --- /dev/null +++ b/forum.json.example @@ -0,0 +1,4 @@ +{ + "recaptchaSecretKey": "", + "recaptchaSiteKey": "" +} \ No newline at end of file diff --git a/license.txt b/license.txt index 3eb168b..cf4ac4a 100644 --- a/license.txt +++ b/license.txt @@ -1,4 +1,4 @@ -Copyright (C) 2018 Andreas Rumpf, Dominik Picheta +Copyright (C) 2015 Andreas Rumpf, Dominik Picheta Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -7,7 +7,7 @@ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR diff --git a/localhost.local/public/css/custom-style.scss b/localhost.local/public/css/custom-style.scss index 6c9e50c..f866829 100644 --- a/localhost.local/public/css/custom-style.scss +++ b/localhost.local/public/css/custom-style.scss @@ -9,8 +9,4 @@ $secondary-btn-color: #f1f1f1; $body-bg: #ffffff; $navbar-color: $body-bg; $navbar-border-color-dark: $body-bg; -$navbar-primary-color: #e80080; - -#main-navbar input#search-box { - border: 1px solid #e6e6e6; -} \ No newline at end of file +$navbar-primary-color: #e80080; \ No newline at end of file diff --git a/nimforum.nimble b/nimforum.nimble index 58a22f7..a24424e 100644 --- a/nimforum.nimble +++ b/nimforum.nimble @@ -1,5 +1,5 @@ # Package -version = "2.1.0" +version = "0.1.0" author = "Dominik Picheta" description = "The Nim forum" license = "MIT" @@ -12,16 +12,16 @@ skipExt = @["nim"] # Dependencies -requires "nim >= 1.0.6" -requires "jester#405be2e" -requires "bcrypt#440c5676ff6" +requires "nim >= 0.14.0" +requires "jester#64295c8" +requires "bcrypt#head" requires "hmac#9c61ebe2fd134cf97" -requires "recaptcha#d06488e" -requires "sass#649e0701fa5c" +requires "recaptcha 1.0.2" +requires "sass" -requires "karax#5f21dcd" +requires "https://github.com/dom96/karax#7a884fb" -requires "webdriver#429933a" +requires "webdriver#a2be578" # Tasks @@ -32,33 +32,26 @@ task backend, "Compiles and runs the forum backend": task runbackend, "Runs the forum backend": exec "./src/forum" -task testbackend, "Runs the forum backend in test mode": - exec "nimble c -r -d:skipRateLimitCheck src/forum.nim" - task frontend, "Builds the necessary JS frontend (with CSS)": exec "nimble c -r src/buildcss" exec "nimble js -d:release src/frontend/forum.nim" mkDir "public/js" - cpFile "src/frontend/forum.js", "public/js/forum.js" + cpFile "src/frontend/nimcache/forum.js", "public/js/forum.js" task minify, "Minifies the JS using Google's closure compiler": exec "closure-compiler public/js/forum.js --js_output_file public/js/forum.js.opt" -task testdb, "Creates a test DB (with admin account!)": +task testdb, "Creates a test DB": exec "nimble c src/setup_nimforum" exec "./src/setup_nimforum --test" -task devdb, "Creates a test DB (with admin account!)": +task devdb, "Creates a test DB": exec "nimble c src/setup_nimforum" exec "./src/setup_nimforum --dev" -task blankdb, "Creates a blank DB": - exec "nimble c src/setup_nimforum" - exec "./src/setup_nimforum --blank" - task test, "Runs tester": exec "nimble c -y src/forum.nim" - exec "nimble c -y -r -d:actionDelayMs=0 tests/browsertester" + exec "nimble c -y -r tests/browsertester" task fasttest, "Runs tester without recompiling backend": - exec "nimble c -r -d:actionDelayMs=0 tests/browsertester" + exec "nimble c -r tests/browsertester" \ No newline at end of file diff --git a/public/css/nimforum.scss b/public/css/nimforum.scss index 2daecdb..ad1d712 100644 --- a/public/css/nimforum.scss +++ b/public/css/nimforum.scss @@ -22,7 +22,6 @@ table th { // Custom styles. // - Navigation bar. $navbar-height: 60px; -$default-category-color: #a3a3a3; $logo-height: $navbar-height - 20px; .navbar-button { @@ -51,7 +50,6 @@ $logo-height: $navbar-height - 20px; // Unfortunately we must colour the controls in the navbar manually. .search-input { @extend .form-input; - min-width: 120px; border-color: $navbar-border-color-dark; } @@ -109,51 +107,12 @@ $logo-height: $navbar-height - 20px; } } -#category-selection { - .dropdown { - .btn { - margin-right: 0px; - } - } - .plus-btn { - margin-right: 0px; - i { - margin-right: 0px; - } - } -} - -.category-description { - opacity: 0.6; - font-size: small; -} - -.category-status { - font-size: small; - font-weight: bold; - - .topic-count { - margin-left: 5px; - opacity: 0.7; - font-size: small; - } -} - -.category { - white-space: nowrap; -} - #new-thread { .modal-container .modal-body { max-height: none; } - .panel-body { - padding-top: $control-padding-y*2; - padding-bottom: $control-padding-y*2; - } - - .form-input[name='subject'] { + .form-input { margin-bottom: $control-padding-y*2; } @@ -184,33 +143,6 @@ $logo-height: $navbar-height - 20px; } } -.thread-list { - @extend .container; - @extend .grid-xl; -} - -.category-list { - @extend .thread-list; - - - .category-title { - @extend .thread-title; - a, a:hover { - color: lighten($body-font-color, 10%); - text-decoration: none; - } - } - - .category-description { - opacity: 0.6; - } -} - -#categories-list .category { - border-left: 6px solid; - border-left-color: $default-category-color; -} - $super-popular-color: #f86713; $popular-color: darken($super-popular-color, 25%); $threads-meta-color: #545d70; @@ -259,12 +191,14 @@ $threads-meta-color: #545d70; } } -.category-color { +.triangle { + // TODO: Abstract this into a "category" class. width: 0; height: 0; - border: 0.25rem solid $default-category-color; + border-left: 0.3rem solid transparent; + border-right: 0.3rem solid transparent; + border-bottom: 0.6rem solid #98c766; display: inline-block; - margin-right: 5px; } .load-more-separator { @@ -301,14 +235,6 @@ $threads-meta-color: #545d70; } } -.thread-replies, .thread-time, .views-text, .popular-text, .centered-header { - text-align: center; -} - -.thread-users { - text-align: left; -} - .thread-time { color: $threads-meta-color; @@ -322,11 +248,8 @@ $threads-meta-color: #545d70; } -// Hide all the avatars but the first on small screens. -@media screen and (max-width: 600px) { - #threads-list a:not(:first-child) > .avatar { - display: none; - } +#threads-list tr.banned { + display: none; // TODO: Fix server so that it doesn't send banned threads. } .posts, .about { @@ -430,7 +353,7 @@ $threads-meta-color: #545d70; } } -.post-content, .about { +.post-content { img { max-width: 100%; } @@ -560,12 +483,6 @@ blockquote { display: none; } -.post-content { - pre:not(.code) { - overflow: scroll; - } -} - .information { @extend .tile; border-top: 1px solid $border-color; @@ -779,3 +696,18 @@ hr { margin-top: $control-padding-y*2; } } + +// - Hide features that have not been implemented yet. +#main-buttons > section.navbar-section:nth-child(1) { + display: none; +} + +#threads-list.table { + tr > th:nth-child(2), tr > td:nth-child(2) { + display: none; + } +} + +.category, div.flag-button { + display: none; +} \ No newline at end of file diff --git a/public/karax.html b/public/karax.html index 3f7f41b..e43498e 100644 --- a/public/karax.html +++ b/public/karax.html @@ -11,21 +11,12 @@ - - - - - + + $scripts