From 1353a0581c037d6d7755a42fa1822eb423034f39 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Tue, 19 Jun 2018 16:20:09 +0100 Subject: [PATCH] Added preliminary files --- CHANGELOG.md | 24 ++++++++++++++++++++++++ LICENSE | 8 +++----- LICENSE.md | 22 ++++++++++++++++++++++ README.md | 13 +++++++++++++ doc/intro.md | 3 +++ project.clj | 7 +++++++ src/adl_support/core.clj | 16 ++++++++++++++++ src/adl_support/tags.clj | 34 ++++++++++++++++++++++++++++++++++ test/adl_support/core_test.clj | 7 +++++++ 9 files changed, 129 insertions(+), 5 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 doc/intro.md create mode 100644 project.clj create mode 100644 src/adl_support/core.clj create mode 100644 src/adl_support/tags.clj create mode 100644 test/adl_support/core_test.clj diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..94f2b99 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,24 @@ +# Change Log +All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). + +## [Unreleased] +### Changed +- Add a new arity to `make-widget-async` to provide a different widget shape. + +## [0.1.1] - 2018-06-17 +### Changed +- Documentation on how to make the widgets. + +### Removed +- `make-widget-sync` - we're all async, all the time. + +### Fixed +- Fixed widget maker to keep working when daylight savings switches over. + +## 0.1.0 - 2018-06-17 +### Added +- Files from the new template. +- Widget maker public API - `make-widget-sync`. + +[Unreleased]: https://github.com/your-name/adl-support/compare/0.1.1...HEAD +[0.1.1]: https://github.com/your-name/adl-support/compare/0.1.0...0.1.1 diff --git a/LICENSE b/LICENSE index f0a9340..df62187 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,4 @@ -MIT License - -Copyright (c) 2018 Simon Brooke +Copyright 2018 Simon Brooke Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -17,5 +15,5 @@ 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. +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..e1c3eab --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,22 @@ + +The MIT License (MIT) + +Copyright (c) 2018 + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a6d5430 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# adl-support + +A Clojure library designed to support auto-generated ADL code. This library should normally be included into projects generated by ADL, and consequently is licenced under the MIT license, which is less restrictive than the GNU General Public License which I normally use. + +## Usage + +FIXME + +## License + +Copyright © 2018 FIXME + +Distributed under the MIT License. diff --git a/doc/intro.md b/doc/intro.md new file mode 100644 index 0000000..30ceced --- /dev/null +++ b/doc/intro.md @@ -0,0 +1,3 @@ +# Introduction to adl-support + +TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) diff --git a/project.clj b/project.clj new file mode 100644 index 0000000..71cb7d1 --- /dev/null +++ b/project.clj @@ -0,0 +1,7 @@ +(defproject adl-support "0.1.0-SNAPSHOT" + :description "A small library of functions called by generated ADL code." + :url "http://example.com/FIXME" + :license {:name "MIT License" + :url "https://opensource.org/licenses/MIT"} + :dependencies [[org.clojure/clojure "1.8.0"] + [selmer "1.10.6"]]) diff --git a/src/adl_support/core.clj b/src/adl_support/core.clj new file mode 100644 index 0000000..0124a59 --- /dev/null +++ b/src/adl_support/core.clj @@ -0,0 +1,16 @@ +(ns adl-support.core + (:require [clojure.string :refer [split]])) + + +(defn query-string-to-map + [query-string] + (reduce + merge + (map + #(let [pair (split % #"=") + value (try + (read-string (nth pair 1)) + (catch Exception _ + (nth pair 1)))] + (hash-map (keyword (first pair) (nth pair 1)))) + (split query-string #"\&")))) diff --git a/src/adl_support/tags.clj b/src/adl_support/tags.clj new file mode 100644 index 0000000..64524df --- /dev/null +++ b/src/adl_support/tags.clj @@ -0,0 +1,34 @@ +(ns adl-support.tags + (:require selmer.node + [selmer.filter-parser :refer [split-filter-val + safe-filter + compile-filter-body + fix-accessor + get-accessor]] + [selmer.filters :refer [filters]] + [selmer.util :refer :all] + [json-html.core :refer [edn->html]]) + (:import [selmer.node INode TextNode FunctionNode])) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; +;;;; adl-support.tags: selmer tags required by ADL selmer views. +;;;; +;;;; This program is free software; you can redistribute it and/or +;;;; modify it under the terms of the MIT-style licence provided; see LICENSE. +;;;; +;;;; This program is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;;; License for more details. +;;;; +;;;; Copyright (C) 2018 Simon Brooke +;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(defn if-writable-handler [params tag-content render rdr] + "If the current element is writable by the current user, emit the content of + the if clause; else emit the content of the else clause." + (let [{if-tags :ifwritable else-tags :else} (tag-content rdr :ifwritable :else :endifwritable)] + params)) diff --git a/test/adl_support/core_test.clj b/test/adl_support/core_test.clj new file mode 100644 index 0000000..d38730a --- /dev/null +++ b/test/adl_support/core_test.clj @@ -0,0 +1,7 @@ +(ns adl-support.core-test + (:require [clojure.test :refer :all] + [adl-support.core :refer :all])) + +(deftest a-test + (testing "FIXME, I fail." + (is (= 0 1))))