From 4f9ac917aee258a4be2350a4e9cb3d8af39b89a8 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Thu, 9 Feb 2017 08:52:42 +0100 Subject: [PATCH] added hierarchic sidbar-pages & refactored namesspace. --- src/cryogen_core/compiler.clj | 6 +++--- src/cryogen_core/{navbar_model.clj => hierarchic.clj} | 10 +++++----- .../{navbar_model_test.clj => hierarchic_test.clj} | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) rename src/cryogen_core/{navbar_model.clj => hierarchic.clj} (82%) rename test/cryogen_core/{navbar_model_test.clj => hierarchic_test.clj} (91%) diff --git a/src/cryogen_core/compiler.clj b/src/cryogen_core/compiler.clj index 353fd8a..c011dee 100644 --- a/src/cryogen_core/compiler.clj +++ b/src/cryogen_core/compiler.clj @@ -15,7 +15,7 @@ [cryogen-core.sitemap :as sitemap] [clojure.inspector :as inspector] [cryogen-core.toc :as toc] - [cryogen-core.navbar-model :as navbar-model]) + [cryogen-core.hierarchic :as hierarchic]) (:import java.util.Locale)) (cache-off!) @@ -512,11 +512,11 @@ :latest-posts latest-posts :navbar-pages (cond (= navbar-model :flat) navbar-pages - (= navbar-model :hierarchic) (navbar-model/build-nav-map navbar-pages) + (= navbar-model :hierarchic) (hierarchic/build-hierarchic-map navbar-pages) ) :sidebar-pages (cond (= navbar-model :flat) sidebar-pages - ;(= navbar-model :hierarchic) (build-nav-map navbar-pages) + (= navbar-model :hierarchic) (hierarchic/build-hierarchic-map sidebar-pages) ) :home-page (if home-page home-page diff --git a/src/cryogen_core/navbar_model.clj b/src/cryogen_core/hierarchic.clj similarity index 82% rename from src/cryogen_core/navbar_model.clj rename to src/cryogen_core/hierarchic.clj index de05418..3a22788 100644 --- a/src/cryogen_core/navbar_model.clj +++ b/src/cryogen_core/hierarchic.clj @@ -1,4 +1,4 @@ -(ns cryogen-core.navbar-model +(ns cryogen-core.hierarchic (:require [clojure.string :as s])) @@ -18,7 +18,7 @@ (filter #(s/starts-with? (:uri %) clean-uri) pages)) ) -(defn build-nav-map-level +(defn build-hierarchic-level "builds one level of nav-map and recurs to next level." [parent-uri pages] (let [current-level (+ 1 (uri-level parent-uri)) @@ -32,12 +32,12 @@ (if (empty? child-pages) page-on-level (merge page-on-level - {:children (build-nav-map-level (:uri page-on-level) child-pages)}))) pages-on-level)) + {:children (build-hierarchic-level (:uri page-on-level) child-pages)}))) pages-on-level)) )) -(defn build-nav-map +(defn build-hierarchic-map "builds a nav-map from pages" [pages] (let [sorted-pages (sort-by :uri pages)] - (build-nav-map-level "/pages/" sorted-pages) + (build-hierarchic-level "/pages/" sorted-pages) )) diff --git a/test/cryogen_core/navbar_model_test.clj b/test/cryogen_core/hierarchic_test.clj similarity index 91% rename from test/cryogen_core/navbar_model_test.clj rename to test/cryogen_core/hierarchic_test.clj index c4887aa..7fd2a9f 100644 --- a/test/cryogen_core/navbar_model_test.clj +++ b/test/cryogen_core/hierarchic_test.clj @@ -1,7 +1,7 @@ -(ns cryogen-core.navbar-model-test +(ns cryogen-core.hierarchic-test (:require [clojure.test :refer :all] - [cryogen-core.navbar-model :as sut])) + [cryogen-core.hierarchic :as sut])) (defn- page [uri page-index] {:uri uri @@ -42,7 +42,7 @@ (is (= 6 (count (sut/filter-pages-for-uri "/pages/nav1.html" pages-dirty)))) )) -(deftest test-navmap-pages +(deftest test-hierarchic-pages (testing "No pages or posts nothing to copy" (let [expected-clean [(enhanced-page @@ -65,8 +65,8 @@ )] ] (is (= expected-clean - (sut/build-nav-map pages-clean))) + (sut/build-hierarchic-map pages-clean))) (is (= expected-dirty - (sut/build-nav-map pages-dirty))) + (sut/build-hierarchic-map pages-dirty))) ) ))