Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
simplify namespace struct
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 committed Sep 11, 2020
1 parent 5c5966f commit 69ef988
Show file tree
Hide file tree
Showing 18 changed files with 140 additions and 126 deletions.
170 changes: 90 additions & 80 deletions cljs-src/project.clj
Original file line number Diff line number Diff line change
@@ -1,91 +1,101 @@
(defproject gooreplacer "3.10.0"
:description "Modify, block URLs & Headers"
:url "https://github.com/jiacai2050/gooreplacer"
:license {:name "MIT"
:url "http://liujiacai.net/license/MIT.html?year=2015"}
:dependencies [[org.clojure/clojure "1.10.0"]
[org.clojure/clojurescript "1.10.597"]
[figwheel-sidecar "0.5.14"]
[org.clojure/core.match "0.3.0-alpha5"]
[org.clojure/data.json "0.2.7"]
[alandipert/storage-atom "2.0.1"]]
:plugins [[lein-figwheel "0.5.14"]
[lein-cljsbuild "1.1.7"]
[lein-doo "0.1.8"]]
:profiles {
;; https://docs.cider.mx/cider/0.23/basics/clojurescript.html#_piggieback
;; cider will jack in piggieback automatically
;; :dev {:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}
:dev {:source-paths ["src/common"]}
:ui-deps {:dependencies [[antizer "0.3.0"]
[cljs-http "0.1.43"]
[org.clojure/core.async "0.3.443"]
[reagent "0.8.1"]]}
:bg-deps {:dependencies []}
:dev-option {:source-paths ["src/option"]
:clean-targets ^{:protect false} [:target-path "resources/dev/option/js"]
:description "Modify, block URLs & Headers"
:url "https://github.com/jiacai2050/gooreplacer"
:license {:name "MIT"
:url "http://liujiacai.net/license/MIT.html?year=2015"}
:dependencies [[org.clojure/clojure "1.10.0"]
[org.clojure/clojurescript "1.10.597"]
[figwheel-sidecar "0.5.14"]
[org.clojure/core.match "0.3.0-alpha5"]
[org.clojure/data.json "0.2.7"]
[alandipert/storage-atom "2.0.1"]

;; ui
[antizer "0.3.0"]
[cljs-http "0.1.43"]
[org.clojure/core.async "0.3.443"]
[reagent "0.8.1"]]
:plugins [[lein-figwheel "0.5.14"]
[lein-cljsbuild "1.1.7"]
[lein-doo "0.1.8"]]
:profiles {
;; https://docs.cider.mx/cider/0.23/basics/clojurescript.html#_piggieback
;; cider will jack in piggieback automatically
;; :dev {:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}
:dev-option {:clean-targets ^{:protect false} [:target-path "resources/dev/option/js"]
:cljsbuild {:builds [{:id "dev"
:figwheel true
:source-paths ["src"]
:compiler {:output-to "resources/dev/option/js/main.js"
:source-map true
:asset-path "js"
:output-dir "resources/dev/option/js"
:optimizations :none
:main gooreplacer.option.core
:verbose true}}]}
:figwheel {:server-port 8080
:http-server-root "dev/option"
:css-dirs ["resources/dev/option/css"]
:server-logfile ".figwheel_option.log"
:repl true}}
:dev-popup {:clean-targets ^{:protect false} [:target-path "resources/dev/popup/js"]
:cljsbuild {:builds [{:id "dev"
:figwheel true
:source-paths ["src/option" "src/common"]
:compiler {:output-to "resources/dev/option/js/main.js"
:compiler {:output-to "resources/dev/popup/js/main.js"
:source-map true
:asset-path "js"
:output-dir "resources/dev/option/js"
:output-dir "resources/dev/popup/js"
:optimizations :none
:main gooreplacer.core
:main gooreplacer.popup.core
:verbose true}}]}
:figwheel {:server-port 8080
:figwheel {:server-port 8081
:http-server-root "dev/option"
:css-dirs ["resources/dev/option/css"]
:server-logfile ".figwheel_option.log"
:server-logfile ".figwheel_popup.log"
:repl true}}
:dev-bg {:source-paths ["src/background" "src/common"]
:clean-targets ^{:protect false} [:target-path "resources/dev/background/js"]
:figwheel {:server-port 8089
:http-server-root "dev/background"
:server-logfile ".figwheel_bg.log"
:repl true}
:cljsbuild {:builds [{:id "dev"
:figwheel true
:source-paths ["src/background" "src/common"]
:compiler {:output-to "resources/dev/background/js/main.js"
:source-map true
:output-dir "resources/dev/background/js"
:asset-path "js"
:main gooreplacer.core
:optimizations :none
:verbose true}}]}}
:release {:clean-targets ^{:protect false} [:target-path
"resources/release/option/js"
"resources/release/background/js"]
:cljsbuild {:builds [{:id "option"
:source-paths ["src/option" "src/common"]
:compiler {:output-to "resources/release/option/main.js"
:output-dir "resources/release/option/js"
:externs ["externs/chrome_extensions.js" "externs/chrome.js"]
:optimizations :advanced
:main gooreplacer.core}}
{:id "background"
:source-paths ["src/background" "src/common"]
:compiler {:output-to "resources/release/background/main.js"
:output-dir "resources/release/background/js"
:externs ["externs/chrome_extensions.js" "externs/chrome.js"]
:optimizations :advanced
:main gooreplacer.core}}]}}
:test {:cljsbuild {:builds [{:id "test"
:source-paths ["test" "src/common"]
:compiler {:output-to "out/main.js"
:main gooreplacer.runner
:optimizations :none}}]}
:doo {:build "test"}}}
:dev-bg {:clean-targets ^{:protect false} [:target-path "resources/dev/background/js"]
:figwheel {:server-port 8089
:http-server-root "dev/background"
:server-logfile ".figwheel_bg.log"
:repl true}
:cljsbuild {:builds [{:id "dev"
:source-paths ["src"]
:figwheel true
:compiler {:output-to "resources/dev/background/js/main.js"
:source-map true
:output-dir "resources/dev/background/js"
:asset-path "js"
:main gooreplacer.background
:optimizations :none
:verbose true}}]}}
:release {:clean-targets ^{:protect false} [:target-path
"resources/release/option/js"
"resources/release/background/js"]
:cljsbuild {:builds [{:id "option"
:compiler {:output-to "resources/release/option/main.js"
:output-dir "resources/release/option/js"
:externs ["externs/chrome_extensions.js" "externs/chrome.js"]
:optimizations :advanced
:main gooreplacer.option.core}}
{:id "background"
:compiler {:output-to "resources/release/background/main.js"
:output-dir "resources/release/background/js"
:externs ["externs/chrome_extensions.js" "externs/chrome.js"]
:optimizations :advanced
:main gooreplacer.background}}]}}
:test {:cljsbuild {:builds [{:id "test"
:compiler {:output-to "out/main.js"
:main gooreplacer.runner
:optimizations :none}}]}
:doo {:build "test"}}}

:aliases {"option" ["with-profile" "dev-option,ui-deps" "do"
["clean"]
["figwheel" "dev"]]
"bg" ["with-profile" "dev-bg,bg-deps" "do"
["clean"]
["figwheel" "dev"]]
"test-and-watch" ["with-profile" "test" "do"
["clean"]
;; First install phantom
["doo" "phantom"]]})
:aliases {"option" ["with-profile" "dev-option" "do"
["clean"]
["figwheel" "dev"]]
"bg" ["with-profile" "dev-bg" "do"
["clean"]
["figwheel" "dev"]]
"test-and-watch" ["with-profile" "test" "do"
["clean"]
;; First install phantom
["doo" "phantom"]]})
2 changes: 1 addition & 1 deletion cljs-src/resources/dev/option/init.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
goog.require("figwheel.connect.build_dev");
goog.require("gooreplacer.core");
goog.require("gooreplacer.option.core");
5 changes: 5 additions & 0 deletions cljs-src/resources/dev/popup/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
<h1>Hello Extensions</h1>
</body>
</html>
2 changes: 1 addition & 1 deletion cljs-src/resources/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "__MSG_appName__",
"version": "3.11.1",
"version": "3.12.0",
"description": "__MSG_appDesc__",
"default_locale": "en",
"permissions": [
Expand Down
3 changes: 0 additions & 3 deletions cljs-src/src/common/gooreplacer/dev.cljs

This file was deleted.

4 changes: 0 additions & 4 deletions cljs-src/src/common/gooreplacer/i18n.cljs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(ns gooreplacer.core
(:require [gooreplacer.tool :as tool]
(ns gooreplacer.background
(:require [gooreplacer.common.tool :as tool]
[clojure.string :as str]
[cljs.core.async :refer [<! >! chan]]
[alandipert.storage-atom]
[gooreplacer.dev]
[gooreplacer.common.dev]
[cljs.core.match :refer-macros [match]])
(:require-macros [gooreplacer.macro :refer [init-db-reader!]]
(:require-macros [gooreplacer.common.macro :refer [init-db-reader!]]
[cljs.core.async.macros :refer [go-loop go]]))

(init-db-reader!)
Expand Down Expand Up @@ -63,4 +63,3 @@
(.addListener js/chrome.browserAction.onClicked
#(.create js/chrome.tabs (clj->js {:url "../option/index.html"})))
(println "listen message done!"))

3 changes: 3 additions & 0 deletions cljs-src/src/gooreplacer/common/dev.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(ns gooreplacer.common.dev)

(enable-console-print!)
4 changes: 4 additions & 0 deletions cljs-src/src/gooreplacer/common/i18n.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(ns gooreplacer.common.i18n
(:require-macros [gooreplacer.common.macro :refer [init-i18n!]]))

(init-i18n!)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns gooreplacer.macro
(ns gooreplacer.common.macro
(:require [clojure.string :as str]
[clojure.java.io :as io]
[clojure.data.json :as json]
Expand All @@ -21,7 +21,7 @@
~(keyword str-name)))
(when-not no-append?
`(defn ~(symbol (str "append-" str-name "!")) [~'rule]
(swap! ~sym-name conj (gooreplacer.tool/encode-rule ~'rule))))]))
(swap! ~sym-name conj (gooreplacer.common.tool/encode-rule ~'rule))))]))
entries))))

(defmacro init-db-reader!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns gooreplacer.macro-test
(:require [gooreplacer.macro :as m]
(ns gooreplacer.common.macro-test
(:require [gooreplacer.common.macro :as m]
[clojure.test :refer [deftest is are]]))

(deftest test-camelcase->kebab
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns gooreplacer.tool
(ns gooreplacer.common.tool
(:require [clojure.string :as str]
[goog.array :as garr]
[goog.object :as gobj]))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
(ns gooreplacer.core
(ns gooreplacer.option.core
(:require [goog.dom :as gdom]
[antizer.reagent :as ant]
[reagent.core :as r]
[gooreplacer.db :as db]
[gooreplacer.io :as io]
[gooreplacer.i18n :as i18n]
[gooreplacer.local-rules :as lr]
[gooreplacer.online-rules :refer [configure-online-form]]))
[gooreplacer.option.db :as db]
[gooreplacer.option.io :as io]
[gooreplacer.common.i18n :as i18n]
[gooreplacer.option.local-rules :as lr]
[gooreplacer.option.online-rules :refer [configure-online-form]]))

(defn top-menu []
[:div
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(ns gooreplacer.db
(ns gooreplacer.option.db
(:require [reagent.core :as r]
[gooreplacer.i18n :as i18n]
[gooreplacer.tool]
[gooreplacer.common.i18n :as i18n]
[gooreplacer.common.tool]
[alandipert.storage-atom :refer [local-storage] :as st])
(:require-macros [gooreplacer.macro :refer [init-database!]]))
(:require-macros [gooreplacer.common.macro :refer [init-database!]]))

(init-database!)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(ns gooreplacer.io
(ns gooreplacer.option.io
(:require [goog.dom :as gdom]
[gooreplacer.db :as db]
[gooreplacer.option.db :as db]
[antizer.reagent :as ant]
[gooreplacer.tool :as tool]))
[gooreplacer.common.tool :as tool]))

(defn normalize-legacy-rule [rule]
(let [src (key rule)
Expand All @@ -14,7 +14,7 @@
:enable enable}))

(defn import-legacy-rules! [rules]
(doseq [rule rules]
(doseq [rule rules]
(db/append-redirect-rules! (normalize-legacy-rule rule))))

(defn import-online-rules! [{:keys [redirect-rules cancel-rules request-headers response-headers rules] :as rs}]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(ns gooreplacer.local-rules
(ns gooreplacer.option.local-rules
(:require [antizer.reagent :as ant]
[clojure.string :as str]
[reagent.core :as r]
[gooreplacer.db :as db]
[gooreplacer.table :as table]
[gooreplacer.tool :as tool]
[gooreplacer.i18n :as i18n]
[gooreplacer.option.db :as db]
[gooreplacer.option.table :as table]
[gooreplacer.common.tool :as tool]
[gooreplacer.common.i18n :as i18n]
[cljs.core.match :refer-macros [match]]))

(def kind-select-opts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(ns gooreplacer.online-rules
(ns gooreplacer.option.online-rules
(:require [antizer.reagent :as ant]
[reagent.core :as r]
[gooreplacer.db :as db]
[gooreplacer.tool :as tool]
[gooreplacer.table :as table]
[gooreplacer.i18n :as i18n]
[gooreplacer.io :as io]
[gooreplacer.option.db :as db]
[gooreplacer.common.tool :as tool]
[gooreplacer.option.table :as table]
[gooreplacer.common.i18n :as i18n]
[gooreplacer.option.io :as io]
[cljs-http.client :as http]
[cljs.core.async :refer [<!]]
[clojure.set :as set]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns gooreplacer.table
(:require [gooreplacer.i18n :as i18n]))
(ns gooreplacer.option.table
(:require [gooreplacer.common.i18n :as i18n]))

(def pagination {:show-size-changer true
:page-size-options ["5" "10" "20"]
Expand Down

0 comments on commit 69ef988

Please sign in to comment.