Skip to content

Commit

Permalink
redesigned library
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan Roxendal committed Apr 11, 2024
1 parent a8774a3 commit 095e07e
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 179 deletions.
25 changes: 19 additions & 6 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,28 @@
</a>
<ul role="navigation" class="mainnav">
<li>
<!-- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-7 h-7 text-white inline-block relative -top-1">
<path d="M8.25 10.875a2.625 2.625 0 1 1 5.25 0 2.625 2.625 0 0 1-5.25 0Z" />
<path fill-rule="evenodd" d="M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25Zm-1.125 4.5a4.125 4.125 0 1 0 2.338 7.524l2.007 2.006a.75.75 0 1 0 1.06-1.06l-2.006-2.007a4.125 4.125 0 0 0-3.399-6.463Z" clip-rule="evenodd" />
</svg> -->
<a href="/bibliotek{{libraryState['queryparams']}}">Biblioteket</a>
</li>
<li>
<a href="/epub">Epubfiler</a>
<!-- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-7 h-7 text-white inline-block relative -top-1">
<path d="M8.25 10.875a2.625 2.625 0 1 1 5.25 0 2.625 2.625 0 0 1-5.25 0Z" />
<path fill-rule="evenodd" d="M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25Zm-1.125 4.5a4.125 4.125 0 1 0 2.338 7.524l2.007 2.006a.75.75 0 1 0 1.06-1.06l-2.006-2.007a4.125 4.125 0 0 0-3.399-6.463Z" clip-rule="evenodd" />
</svg> -->
<a ng-click="$broadcast('show_autocomplete')" title="Snabbkommando: 's'">Snabbsökning</a>
</li>
<li>
<a href="/ljudochbild/">Ljud <em>&</em> bild</a>
</li>
<li>
<a ng-click="$broadcast('show_autocomplete')" title="Snabbkommando: 's'">Snabbsökning</a>
<!-- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-7 h-7 text-white inline-block relative -top-1">
<path d="M8.25 10.875a2.625 2.625 0 1 1 5.25 0 2.625 2.625 0 0 1-5.25 0Z" />
<path fill-rule="evenodd" d="M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25Zm-1.125 4.5a4.125 4.125 0 1 0 2.338 7.524l2.007 2.006a.75.75 0 1 0 1.06-1.06l-2.006-2.007a4.125 4.125 0 0 0-3.399-6.463Z" clip-rule="evenodd" />
</svg> -->
<a ng-href="/sök{{searchState['queryparams']}}">Sök i texterna</a>
</li>
<li>
<a ng-href="/sök{{searchState['queryparams']}}">Sök i texterna</a>
<a href="/bibliotek?visa=epub&sort=popularitet">Hämta e-böcker</a>
</li>
<li>
<a href="/presentationer">Presentationer</a>
Expand All @@ -149,6 +158,10 @@
<li>
<a href="/dramawebben">Dramawebben</a>
</li>
<li>
<a href="/ljudochbild/">Ljud <em>&</em> bild</a>
</li>

<li>
<a href="/skolan/">Skolan</a>
</li>
Expand Down
45 changes: 0 additions & 45 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,6 @@ window.littb = angular
route = [route]
}
for (let r of route) {
// if (r.split("/")[1] === "författare") {
// const shortRoute = r
// .replace(/^\/författare\//, "/f/")
// .replace("/titlar/", "/t/")
// $routeProvider.when(shortRoute, obj)
// }

$routeProvider.when(r, obj)
}
return this
Expand Down Expand Up @@ -488,44 +481,6 @@ window.littb = angular
]
})

.when("/f/:author/t/:title/:mediatype", {
redirectTo(routeParams, path, searchVars) {
console.log("searchVars", path, searchVars)

let suffix = _.toPairs(searchVars)
.map(([key, val]) => {
if (val === true) {
return key
} else {
return key + "=" + val
}
})
.join("&")
return (
`/författare/${routeParams.author}/titlar/${routeParams.title}/${
{ e: "etext", f: "faksimil" }[routeParams.mediatype]
}` + (suffix ? "?" + suffix : "")
)
}
})
.when(
[
"/f/:author/t/:title/sida/:pagename/:mediatype",
"/f/:author/t/:title/s/:pagename/:mediatype"
],
{
redirectTo(routeParams, path, searchVars) {
return `/författare/${routeParams.author}/titlar/${
routeParams.title
}/sida/${routeParams.pagename}/${
{ e: "etext", f: "faksimil" }[routeParams.mediatype] ||
routeParams.mediatype
}`
}
}
)
// .when("/författare/:author/titlar/:title/:mediatype", {

.when(
[
"/författare/:author/titlar/:title/:mediatype",
Expand Down
4 changes: 3 additions & 1 deletion app/scripts/components/reader/reading_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ export default [
case "F21":
case "u":
if (s.workinfo.urn) {
navigator.clipboard.writeText(s.workinfo.urn)
navigator.clipboard.writeText(
"https://urn.kb.se/resolve?urn=" + s.workinfo.urn
)
s.$emit("notify", "Kopierade urn")
} else {
s.$emit("notify", "Ingen urn hittades")
Expand Down
10 changes: 10 additions & 0 deletions app/scripts/library_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,16 @@ littb.controller(
}
s.sortItems["epub"] = _.cloneDeep(s.sortItems.works)

s.tabObjects = [
{ label: "Enkel sökning", value: "enkel", current: true },
{ label: "Utökad sökning", value: "utökad", current: false }
// { label: "Avancerad", value: "avancerad", current: false }
]
s.tabClick = function (tab) {
s.tabObjects.forEach(tab => (tab.current = false))
tab.current = true
}

s.refreshData = function (isInitial) {
if (!isInitial) {
s.relevance_page.current = 1
Expand Down
12 changes: 8 additions & 4 deletions app/scripts/search_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ littb.controller(
args.include_modernized = false
}

// args.sort_field = "sortfield"
args.sort_field = null

return args
}

Expand Down Expand Up @@ -608,10 +611,11 @@ littb.controller(
hasSearchInit = true
})
$q.all([def, authors]).then(function ([[sentsWithHeaders, author_aggs]]) {
s.authorStatsData = _.orderBy(
author_aggs,
auth => s.authorsById[auth.authorid].name_for_index
)
// s.authorStatsData = _.orderBy(
// author_aggs,
// auth => s.authorsById[auth.authorid].name_for_index
// )
s.authorStatsData = author_aggs
})
return def
}
Expand Down
17 changes: 8 additions & 9 deletions app/scripts/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { fromFilters } from "./query.ts"
const littb = angular.module("littbApp")
let SIZE_VALS = [625, 750, 1100, 1500, 2050]

// let STRIX_URL = "http://" + location.host.split(":")[0] + ":5001"
let STRIX_URL = "http://" + location.host.split(":")[0] + ":5001"
// let STRIX_URL = "https://litteraturbanken.se/api"
let STRIX_URL = "/api"
// let STRIX_URL = "/api"

if (
_.str.startsWith(location.host, "red.l") ||
Expand Down Expand Up @@ -183,7 +183,7 @@ const expandMediatypes = function (works, mainMediatype) {
return output
}

littb.factory("backend", function ($http, $q, util, $timeout, $sce, $location) {
littb.factory("backend", function ($http, $q, util, $timeout, $sce, $location, $filter) {
// $http.defaults.transformResponse = (data, headers) ->
// localStorageCache = $angularCacheFactory "localStorageCache",
// storageMode: 'localStorage'
Expand Down Expand Up @@ -429,7 +429,8 @@ littb.factory("backend", function ($http, $q, util, $timeout, $sce, $location) {
"text,parts,sourcedesc,pages,errata,intro,workintro,content,article.ArticleText,works,intro_text,bibliography_types,wikidata.wikipedia_text,content_vector",
// author_aggregation: author_aggs,
...options,
search: filters
search: filters,
vectorize: true
},
val => _.isNil(val) || (_.isPlainObject(val) && _.isEmpty(val))
)
Expand Down Expand Up @@ -1130,10 +1131,6 @@ littb.factory("backend", function ($http, $q, util, $timeout, $sce, $location) {
label: content.suggest[0].text,
typeLabel: "Menade du",
action(scope) {
// c.log ("autoc", @autocomplete)
// return scope.autocomplete(content.suggest[0].text)
// scope.autocomplete(content.suggest[0].text).then (data) ->
// scope.$apply () ->
$("#autocomplete")
.controller("ngModel")
.$setViewValue(content.suggest[0].text)
Expand Down Expand Up @@ -1166,8 +1163,10 @@ littb.factory("backend", function ($http, $q, util, $timeout, $sce, $location) {
}

if (item.doc_type === "author") {
let year = $filter("authorYear")(item)

item.url = `/författare/${item.authorid}`
item.label = item.name_for_index
item.label = item.name_for_index + (year ? ` (${year})` : "")
item.typeLabel = "Författare"
}

Expand Down
39 changes: 24 additions & 15 deletions app/styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ th {
min-height : 500px;
}

.rzslider {
max-width: 600px;
}

.rzslider .rz-pointer {
width: 15px;
height: 15px;
Expand Down Expand Up @@ -1359,6 +1363,7 @@ body > .header {
// .top_row .submit {display : none;}
// .top_row .spinner {display : inline-block;}
// }
background-size: cover !important;
.lb-logo {
--logo-l-color: var(--primary-color);
--logo-b-color: black;
Expand Down Expand Up @@ -2280,7 +2285,7 @@ body > .header {
.btn:active, .btn.active {
box-shadow: none;
/* border: 2px inset #7a1400; */
background-color: darkgrey;
background-color: var(--primary-color);
color: white;
border-color: #333;
}
Expand Down Expand Up @@ -2321,12 +2326,12 @@ body > .header {
.filter_input, .keyword_select {
border : 1px solid #333;
// margin-top : 0.4em;
max-width: 300px;
padding: 8px;
max-width: 450px;
// padding: 8px;
color: #333;
font-size: 0.8em;
padding-bottom: 6px;
padding-left: 19px;
// font-size: 0.8em;
// padding-bottom: 6px;
// padding-left: 19px;
vertical-align: middle;
}

Expand All @@ -2340,8 +2345,8 @@ body > .header {

}
.main_input {
margin-bottom: 4px;
margin-bottom: 1em;
// margin-bottom: 4px;
// margin-bottom: 1em;
}
.select2-container {
// width : 100% !important;
Expand Down Expand Up @@ -2449,11 +2454,11 @@ body > .header {
margin-right: 0.2em;
margin-bottom: 0.3em;
&:hover {
background-color : #999 !important;
background-color : var(--primary-color) !important;
}
&.active {
box-shadow: none;
background-color: #999 !important;
background-color: var(--primary-color) !important;
color : white;
}
&:focus {
Expand Down Expand Up @@ -2493,10 +2498,10 @@ body > .header {
}
.submit.btn {
background-color: white;
border: 1px solid #333;
border: 2px solid $primarycolor;
vertical-align: middle;
padding-right: 12px;
padding-left: 12px;
// padding-right: 12px;
// padding-left: 12px;
}
th {
padding-bottom : 1em;
Expand Down Expand Up @@ -2582,8 +2587,12 @@ body > .header {
}
.result {
table {
border-spacing: 8px 2px;
border-collapse: separate;
border-spacing: 0;
border-collapse: collapse;
td {
padding: 1px 0.5em;

}
}
.header_container {
max-width : calc(100% - 2rem);
Expand Down
2 changes: 1 addition & 1 deletion app/views/epubList.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- <img bkg-img src="img/ljudlandskap.jpg"></img> -->

<div ng-class="{searching : searching}"><!-- for some reason, this breaks if dedented -->
<h1 class="preamble">Litteraturbankens epubfiler</h1>
<h1 class="preamble">Hämta eböcker</h1>

<p class="preamble">Det här är en lista över de titlar som Litteraturbanken erbjuder i formatet <em>epub</em>
– ett filformat som passar för de flesta mobila läsare, t. ex. läsplattor, surfplattor och mobiltelefoner.
Expand Down
Loading

0 comments on commit 095e07e

Please sign in to comment.