feeds-fun 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feeds-fun",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "author": "Aliaksei Yaletski (Tiendil) <a.eletsky@gmail.com> (https://tiendil.org/)",
5
5
  "description": "Frontend for the Feeds Fun — web-based news reader",
6
6
  "keywords": [
@@ -41,7 +41,9 @@
41
41
 
42
42
  <template v-if="showTags">
43
43
  <br />
44
- <tags-list :tags="entry.tags" />
44
+ <tags-list
45
+ :tags="entry.tags"
46
+ :contributions="entry.scoreContributions" />
45
47
  </template>
46
48
 
47
49
  <div
@@ -77,7 +77,8 @@
77
77
  .tag {
78
78
  display: inline-block;
79
79
  cursor: pointer;
80
- padding: 0.25rem;
80
+ padding: 0.1rem;
81
+ margin-right: 0.2rem;
81
82
  white-space: nowrap;
82
83
  }
83
84
 
@@ -92,4 +93,12 @@
92
93
  .tag.excluded {
93
94
  background-color: #ffcccc;
94
95
  }
96
+
97
+ .tag.positive {
98
+ color: darkgreen;
99
+ }
100
+
101
+ .tag.negative {
102
+ color: darkred;
103
+ }
95
104
  </style>
@@ -9,7 +9,7 @@
9
9
  v-for="tag of displayedTags"
10
10
  :key="tag"
11
11
  :uid="tag"
12
- :mode="!!selectedTags[tag] ? 'selected' : null"
12
+ :mode="tagMode(tag)"
13
13
  :count="entriesStore.reportTagsCount[tag]"
14
14
  count-mode="tooltip"
15
15
  @tag:clicked="onTagClicked" />
@@ -41,7 +41,7 @@
41
41
 
42
42
  const selectedTags = ref<{[key: string]: boolean}>({});
43
43
 
44
- const properties = defineProps<{tags: string[]}>();
44
+ const properties = defineProps<{tags: string[]; contributions: {[key: string]: number}}>();
45
45
 
46
46
  const tagsNumber = computed(() => {
47
47
  return properties.tags.length;
@@ -55,6 +55,32 @@
55
55
  return preparedTags.value.slice(0, showLimit.value);
56
56
  });
57
57
 
58
+ function tagMode(tag: string) {
59
+ if (!!selectedTags.value[tag]) {
60
+ return "selected";
61
+ }
62
+
63
+ // return null;
64
+
65
+ if (!properties.contributions) {
66
+ return null;
67
+ }
68
+
69
+ if (!(tag in properties.contributions)) {
70
+ return null;
71
+ }
72
+
73
+ if (properties.contributions[tag] == 0) {
74
+ return null;
75
+ }
76
+
77
+ if (properties.contributions[tag] > 0) {
78
+ return "positive";
79
+ }
80
+
81
+ return "negative";
82
+ }
83
+
58
84
  const preparedTags = computed(() => {
59
85
  const values = [];
60
86
 
@@ -63,6 +89,17 @@
63
89
  }
64
90
 
65
91
  values.sort((a, b) => {
92
+ const aContributions = Math.abs(properties.contributions[a] || 0);
93
+ const bContributions = Math.abs(properties.contributions[b] || 0);
94
+
95
+ if (aContributions > bContributions) {
96
+ return -1;
97
+ }
98
+
99
+ if (aContributions < bContributions) {
100
+ return 1;
101
+ }
102
+
66
103
  const aCount = entriesStore.reportTagsCount[a];
67
104
  const bCount = entriesStore.reportTagsCount[b];
68
105
 
@@ -114,6 +114,7 @@ export class Entry {
114
114
  readonly tags: string[];
115
115
  readonly markers: e.Marker[];
116
116
  readonly score: number;
117
+ readonly scoreContributions: {[key: string]: number};
117
118
  readonly scoreToZero: number;
118
119
  readonly publishedAt: Date;
119
120
  readonly catalogedAt: Date;
@@ -127,6 +128,7 @@ export class Entry {
127
128
  tags,
128
129
  markers,
129
130
  score,
131
+ scoreContributions,
130
132
  publishedAt,
131
133
  catalogedAt,
132
134
  body
@@ -138,6 +140,7 @@ export class Entry {
138
140
  tags: string[];
139
141
  markers: e.Marker[];
140
142
  score: number;
143
+ scoreContributions: {[key: string]: number};
141
144
  publishedAt: Date;
142
145
  catalogedAt: Date;
143
146
  body: string | null;
@@ -149,6 +152,7 @@ export class Entry {
149
152
  this.tags = tags;
150
153
  this.markers = markers;
151
154
  this.score = score;
155
+ this.scoreContributions = scoreContributions;
152
156
  this.publishedAt = publishedAt;
153
157
  this.catalogedAt = catalogedAt;
154
158
  this.body = body;
@@ -181,6 +185,7 @@ export function entryFromJSON({
181
185
  tags,
182
186
  markers,
183
187
  score,
188
+ scoreContributions,
184
189
  publishedAt,
185
190
  catalogedAt,
186
191
  body
@@ -192,6 +197,7 @@ export function entryFromJSON({
192
197
  tags: string[];
193
198
  markers: string[];
194
199
  score: number;
200
+ scoreContributions: {[key: string]: number};
195
201
  publishedAt: string;
196
202
  catalogedAt: string;
197
203
  body: string | null;
@@ -210,6 +216,7 @@ export function entryFromJSON({
210
216
  throw new Error(`Unknown marker: ${m}`);
211
217
  }),
212
218
  score: score,
219
+ scoreContributions: scoreContributions,
213
220
  publishedAt: new Date(publishedAt),
214
221
  catalogedAt: new Date(catalogedAt),
215
222
  body: body
@@ -36,7 +36,7 @@
36
36
  .score {
37
37
  display: inline-block;
38
38
  cursor: pointer;
39
- padding: 0.25rem;
39
+ padding: 0.1rem;
40
40
  background-color: #c1c1ff;
41
41
  }
42
42
  </style>
@@ -67,7 +67,7 @@
67
67
  const valueB = _.get(b, orderField, null);
68
68
 
69
69
  if (valueA === null && valueB === null) {
70
- return 0;
70
+ return utils.compareLexicographically(a.tags, b.tags);
71
71
  }
72
72
 
73
73
  if (valueA === null) {
@@ -86,7 +86,7 @@
86
86
  return -1 * direction;
87
87
  }
88
88
 
89
- return 0;
89
+ return utils.compareLexicographically(a.tags, b.tags);
90
90
  });
91
91
 
92
92
  return sorted;