~bendersteed/wikisophy-fe

4423776bd4de82ebc8066de4fa2357b87966296e — Dimakakos Dimos 4 years ago
Add: first commit, setup of project and some configuration
A  => .gitignore +16 -0
@@ 1,16 @@
/target
/classes
/checkouts
profiles.clj
pom.xml
pom.xml.asc
*.jar
*.class
/.lein-*
/.nrepl-port
/resources/public/js
/public/js
/out
/.repl
*.log
/.env

A  => LICENSE +22 -0
@@ 1,22 @@
The MIT License (MIT)

Copyright (c) 2014 reagent-project

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 the Software without restriction, including without limitation the rights
to 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
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


A  => README.md +22 -0
@@ 1,22 @@

### Development mode
To start the Figwheel compiler, navigate to the project folder and run the following command in the terminal:

```
lein figwheel
```

Figwheel will automatically push cljs changes to the browser.
Once Figwheel starts up, you should be able to open the `public/index.html` page in the browser.

### REPL

The project is setup to start nREPL on port `7002` once Figwheel starts.
Once you connect to the nREPL, run `(cljs)` to switch to the ClojureScript REPL.

### Building for production

```
lein clean
lein package
```

A  => env/dev/clj/user.clj +11 -0
@@ 1,11 @@
(ns user
 (:require [figwheel-sidecar.repl-api :as ra]))

(defn start-fw []
 (ra/start-figwheel!))

(defn stop-fw []
 (ra/stop-figwheel!))

(defn cljs []
 (ra/cljs-repl))

A  => env/dev/cljs/wikisophy/dev.cljs +15 -0
@@ 1,15 @@
(ns ^:figwheel-no-load wikisophy.dev
  (:require
    [wikisophy.core :as core]
    [devtools.core :as devtools]))

(extend-protocol IPrintWithWriter
  js/Symbol
  (-pr-writer [sym writer _]
    (-write writer (str "\"" (.toString sym) "\""))))

(enable-console-print!)

(devtools/install!)

(core/init!)

A  => env/prod/cljs/wikisophy/prod.cljs +8 -0
@@ 1,8 @@
(ns wikisophy.prod
  (:require
    [wikisophy.core :as core]))

;;ignore println statements in prod
(set! *print-fn* (fn [& _]))

(core/init!)

A  => project.clj +57 -0
@@ 1,57 @@
(defproject wikisophy "0.1.0-SNAPSHOT"
  :description "A Reagent content that consumes an array of titles and
  links of the path taken through wikipedia articles' first link
  leading mostly to wikipedia."
  :url "https://wikisophy.bendersteed.tech"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :dependencies [[org.clojure/clojure "1.10.1"]
                 [org.clojure/clojurescript "1.10.597"]
                 [reagent "0.9.0-rc3"]]

  :plugins [[lein-cljsbuild "1.1.7"]
            [lein-figwheel "0.5.19"]]

  :clean-targets ^{:protect false}

  [:target-path
   [:cljsbuild :builds :app :compiler :output-dir]
   [:cljsbuild :builds :app :compiler :output-to]]

  :resource-paths ["public"]

  :figwheel {:http-server-root "."
             :nrepl-port 7002
             :nrepl-middleware [cider.piggieback/wrap-cljs-repl]
             :css-dirs ["public/css"]}

  :cljsbuild {:builds {:app
                       {:source-paths ["src" "env/dev/cljs"]
                        :compiler
                        {:main "wikisophy.dev"
                         :output-to "public/js/app.js"
                         :output-dir "public/js/out"
                         :asset-path   "js/out"
                         :source-map true
                         :optimizations :none
                         :pretty-print  true}
                        :figwheel
                        {:on-jsload "wikisophy.core/mount-root"
                         :open-urls ["http://localhost:3449/index.html"]}}
                       :release
                       {:source-paths ["src" "env/prod/cljs"]
                        :compiler
                        {:output-to "public/js/app.js"
                         :output-dir "public/js/release"
                         :optimizations :advanced
                         :infer-externs true
                         :pretty-print false}}}}

  :aliases {"package" ["do" "clean" ["cljsbuild" "once" "release"]]}

  :profiles {:dev {:source-paths ["src" "env/dev/clj"]
                   :dependencies [[binaryage/devtools "0.9.11"]
                                  [figwheel-sidecar "0.5.19"]
                                  [nrepl "0.6.0"]
                                  [cider/piggieback "0.4.2"]]}})

A  => public/css/site.css +34 -0
@@ 1,34 @@
body {
  font-family: 'Helvetica Neue', Verdana, Helvetica, Arial, sans-serif;
  max-width: 600px;
  margin: 0 auto;
  padding-top: 72px;
  -webkit-font-smoothing: antialiased;
  font-size: 1.125em;
  color: #333;
  line-height: 1.5em;
}

h1, h2, h3 {
  color: #000;
}
h1 {
  font-size: 2.5em
}

h2 {
  font-size: 2em
}

h3 {
  font-size: 1.5em
}

a {
  text-decoration: none;
  color: #09f;
}

a:hover {
  text-decoration: underline;
}

A  => public/index.html +17 -0
@@ 1,17 @@

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1" name="viewport">
    <link href="/css/site.css" rel="stylesheet" type="text/css">
  </head>
  <body>
    <div id="app">
      <h3>ClojureScript has not been compiled!</h3>
      <p>please run <b>lein figwheel</b> in order to start the compiler</p>
    </div>
    <script src="/js/app.js" type="text/javascript"></script>
    
  </body>
</html>

A  => src/wikisophy/core.cljs +21 -0
@@ 1,21 @@
(ns wikisophy.core
    (:require
      [reagent.core :as r]))

;; -------------------------
;; Views

(defn home-page []
  [:div [:h2 "Welcome to Reagent"]
   [:p "This was so fucking shitty, for real I hate this stuff."]
   [:p "Testing if figwheel still works..."]
   [:p "It does actually! Nice. Let's get to work then!"]])

;; -------------------------
;; Initialize app

(defn mount-root []
  (r/render [home-page] (.getElementById js/document "app")))

(defn init! []
  (mount-root))