Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff72e3ed37 | ||
|
|
2398ab4fe6 | ||
|
|
951a405c4c | ||
|
|
2e8e292b01 | ||
|
|
b045b23e04 |
@@ -4,7 +4,19 @@
|
||||
# Should we show book covers or just the names?
|
||||
module DiscourseRewind
|
||||
class Rewind::Action::ReadingTime < Rewind::Action::BaseReport
|
||||
FakeData = {
|
||||
data: {
|
||||
reading_time: 2_880_000,
|
||||
book: "The Combined Cosmere works + Wheel of Time",
|
||||
isbn: "978-0812511819",
|
||||
series: true,
|
||||
},
|
||||
identifier: "reading-time",
|
||||
}
|
||||
|
||||
def call
|
||||
return FakeData if Rails.env.development?
|
||||
|
||||
reading_time = UserVisit.where(user_id: user.id).where(visited_at: date).sum(:time_read)
|
||||
book = best_book_fit(reading_time)
|
||||
|
||||
@@ -15,6 +27,7 @@ module DiscourseRewind
|
||||
reading_time: reading_time,
|
||||
book: book[:title],
|
||||
isbn: book[:isbn],
|
||||
series: book[:series],
|
||||
},
|
||||
identifier: "reading-time",
|
||||
}
|
||||
@@ -105,30 +118,37 @@ module DiscourseRewind
|
||||
"The Complete works of Shakespeare" => {
|
||||
reading_time: 180_000,
|
||||
isbn: "978-1853268953",
|
||||
series: true,
|
||||
},
|
||||
"The Game of Thrones Series" => {
|
||||
reading_time: 360_000,
|
||||
isbn: "978-0007477159",
|
||||
series: true,
|
||||
},
|
||||
"Malazan Book of the Fallen" => {
|
||||
reading_time: 720_000,
|
||||
isbn: "978-0765348821",
|
||||
series: true,
|
||||
},
|
||||
"Terry Pratchett’s Discworld series" => {
|
||||
reading_time: 1_440_000,
|
||||
isbn: "978-9123684458",
|
||||
series: true,
|
||||
},
|
||||
"The Wandering Inn web series" => {
|
||||
reading_time: 2_160_000,
|
||||
isbn: "the-wandering-inn",
|
||||
series: true,
|
||||
},
|
||||
"The Combined Cosmere works + Wheel of Time" => {
|
||||
reading_time: 2_880_000,
|
||||
isbn: "978-0812511819",
|
||||
series: true,
|
||||
},
|
||||
"The Star Trek novels" => {
|
||||
reading_time: 3_600_000,
|
||||
isbn: "978-1852860691",
|
||||
series: true,
|
||||
},
|
||||
}.symbolize_keys
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ module DiscourseRewind
|
||||
{ word: "what", score: 100 },
|
||||
{ word: "have", score: 90 },
|
||||
{ word: "you", score: 80 },
|
||||
{ word: "achieved", score: 70 },
|
||||
{ word: "overachieved", score: 70 },
|
||||
{ word: "this", score: 60 },
|
||||
{ word: "week", score: 50 },
|
||||
],
|
||||
|
||||
@@ -11,10 +11,10 @@ const FavoriteTags = <template>
|
||||
<div class="rewind-report-container">
|
||||
{{#each @report.data as |data|}}
|
||||
<a class="rewind-card" href={{concat "/tag/" data.name}}>
|
||||
<a
|
||||
<p
|
||||
class="favorite-tags__tag"
|
||||
href={{concat "/tag/" data.name}}
|
||||
>#{{data.name}}</a>
|
||||
>#{{data.name}}</p>
|
||||
</a>
|
||||
{{/each}}
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,13 @@ export default class ReadingTime extends Component {
|
||||
let leftOverMinutes = totalMinutes % 60;
|
||||
let totalHours = (totalMinutes - leftOverMinutes) / 60;
|
||||
|
||||
return `${totalHours}h ${leftOverMinutes}m`;
|
||||
if (leftOverMinutes >= 35) {
|
||||
totalHours += 1;
|
||||
leftOverMinutes = 0;
|
||||
return `${totalHours}h`;
|
||||
} else {
|
||||
return `${totalHours}h ${leftOverMinutes}m`;
|
||||
}
|
||||
}
|
||||
|
||||
<template>
|
||||
@@ -34,6 +40,11 @@ export default class ReadingTime extends Component {
|
||||
src="/plugins/discourse-rewind/images/books/{{@report.data.isbn}}.jpg"
|
||||
/>
|
||||
</div>
|
||||
{{#if @report.data.series}}
|
||||
<div class="book-series one"></div>
|
||||
<div class="book-series two"></div>
|
||||
<div class="book-series three"></div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { on } from "@ember/modifier";
|
||||
import { action } from "@ember/object";
|
||||
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
import concatClass from "discourse/helpers/concat-class";
|
||||
import emoji from "discourse/helpers/emoji";
|
||||
import discourseLater from "discourse-common/lib/later";
|
||||
|
||||
@@ -45,6 +46,10 @@ export default class WordCard extends Component {
|
||||
};
|
||||
}
|
||||
|
||||
get longWord() {
|
||||
return this.args.word.length >= 7;
|
||||
}
|
||||
|
||||
get cardStyle() {
|
||||
return htmlSafe(`${this.randomStyle}; ${this.mysteryData.color};`);
|
||||
}
|
||||
@@ -72,7 +77,10 @@ export default class WordCard extends Component {
|
||||
<div
|
||||
{{on "click" this.handleClick}}
|
||||
{{on "mouseleave" this.handleLeave}}
|
||||
class="rewind-card__wrapper"
|
||||
class={{concatClass
|
||||
"rewind-card__wrapper"
|
||||
(if this.longWord "-long-word")
|
||||
}}
|
||||
style={{this.cardStyle}}
|
||||
{{didInsert this.registerCardContainer}}
|
||||
role="button"
|
||||
|
||||
@@ -1 +1 @@
|
||||
<Rewind />
|
||||
<Rewind />
|
||||
@@ -4,9 +4,13 @@
|
||||
gap: 0.5em;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.rewind-card {
|
||||
@include rewind-border;
|
||||
width: max-content;
|
||||
flex-grow: 1;
|
||||
&:hover {
|
||||
background-color: var(--secondary-very-high);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
position: relative;
|
||||
transform-style: preserve-3d;
|
||||
transform: rotateY(-20deg);
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
p.reading-time__text {
|
||||
@@ -76,8 +77,8 @@ p.reading-time__text {
|
||||
#fff 80%,
|
||||
#f9f9f9 85%,
|
||||
#fff 90%,
|
||||
#f9f9f9 95%,
|
||||
#fff 100%
|
||||
#b6b6b6 95%,
|
||||
#b6b6b6 100%
|
||||
);
|
||||
}
|
||||
|
||||
@@ -91,6 +92,7 @@ p.reading-time__text {
|
||||
transform: translateZ(-17.5px);
|
||||
background-color: var(--book-color);
|
||||
border-radius: 0 5px 5px 0;
|
||||
box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.25);
|
||||
@media screen and (width <= 475px) {
|
||||
width: 100px;
|
||||
height: 133px;
|
||||
@@ -115,6 +117,87 @@ p.reading-time__text {
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
background-color: var(--secondary);
|
||||
--book-color: rgba(var(--primary-rgb), 0.4);
|
||||
--book-color: var(--primary-very-high);
|
||||
@include rewind-border;
|
||||
}
|
||||
|
||||
.book-series {
|
||||
width: 150px;
|
||||
height: 200px;
|
||||
@media screen and (width <= 475px) {
|
||||
width: 100px;
|
||||
height: 133px;
|
||||
}
|
||||
position: relative;
|
||||
transform-style: preserve-3d;
|
||||
transform: rotateY(-20deg);
|
||||
position: absolute;
|
||||
background-color: var(--book-color);
|
||||
border-radius: 0 5px 5px 0;
|
||||
box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.25);
|
||||
z-index: 1;
|
||||
&::before {
|
||||
position: absolute;
|
||||
content: " ";
|
||||
background-color: blue;
|
||||
left: 0;
|
||||
top: 4px;
|
||||
width: 33px;
|
||||
height: 192px;
|
||||
@media screen and (width <= 475px) {
|
||||
left: -43px;
|
||||
width: 22px;
|
||||
height: 125px;
|
||||
}
|
||||
transform: translateX(128.5px) rotateY(90deg);
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
#fff 0%,
|
||||
#f9f9f9 5%,
|
||||
#fff 10%,
|
||||
#f9f9f9 15%,
|
||||
#fff 20%,
|
||||
#f9f9f9 25%,
|
||||
#fff 30%,
|
||||
#f9f9f9 35%,
|
||||
#fff 40%,
|
||||
#f9f9f9 45%,
|
||||
#fff 50%,
|
||||
#f9f9f9 55%,
|
||||
#fff 60%,
|
||||
#f9f9f9 65%,
|
||||
#fff 70%,
|
||||
#f9f9f9 75%,
|
||||
#fff 80%,
|
||||
#f9f9f9 85%,
|
||||
#fff 90%,
|
||||
#b6b6b6 95%,
|
||||
#b6b6b6 100%
|
||||
);
|
||||
}
|
||||
&.one {
|
||||
top: 3px;
|
||||
left: 14px;
|
||||
@media screen and (width <= 475px) {
|
||||
top: 3px;
|
||||
left: 11px;
|
||||
}
|
||||
}
|
||||
&.two {
|
||||
top: 5px;
|
||||
left: 22px;
|
||||
z-index: -1;
|
||||
@media screen and (width <= 475px) {
|
||||
top: 5px;
|
||||
left: 17px;
|
||||
}
|
||||
}
|
||||
&.three {
|
||||
top: 7px;
|
||||
left: 31px;
|
||||
z-index: -2;
|
||||
@media screen and (width <= 475px) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,16 @@
|
||||
0 0 / 6px 6px,
|
||||
var(--secondary-low);
|
||||
}
|
||||
&.-long-word .rewind-card__title {
|
||||
font-size: var(--font-0);
|
||||
}
|
||||
&.-long-word .rewind-card {
|
||||
padding: 2px;
|
||||
}
|
||||
.rewind-card__title {
|
||||
overflow-wrap: anywhere;
|
||||
hyphens: auto;
|
||||
}
|
||||
.rewind-card__image {
|
||||
image-rendering: pixelated;
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 207 KiB After Width: | Height: | Size: 145 KiB |
|
Before Width: | Height: | Size: 161 KiB After Width: | Height: | Size: 178 KiB |
|
Before Width: | Height: | Size: 227 KiB After Width: | Height: | Size: 130 KiB |
|
Before Width: | Height: | Size: 141 KiB After Width: | Height: | Size: 106 KiB |