radames commited on
Commit
2e647a6
·
1 Parent(s): 4b311c3

using tailwind tygraphy

Browse files
client/package-lock.json CHANGED
@@ -10,6 +10,7 @@
10
  "devDependencies": {
11
  "@sveltejs/adapter-static": "^1.0.0-next.28",
12
  "@sveltejs/kit": "next",
 
13
  "autoprefixer": "^10.4.2",
14
  "eslint": "^7.32.0",
15
  "eslint-config-prettier": "^8.3.0",
@@ -267,6 +268,20 @@
267
  }
268
  }
269
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  "node_modules/@types/parse-json": {
271
  "version": "4.0.0",
272
  "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz",
@@ -1420,6 +1435,18 @@
1420
  "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==",
1421
  "dev": true
1422
  },
 
 
 
 
 
 
 
 
 
 
 
 
1423
  "node_modules/lodash.merge": {
1424
  "version": "4.6.2",
1425
  "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
@@ -2884,6 +2911,17 @@
2884
  "svelte-hmr": "^0.14.9"
2885
  }
2886
  },
 
 
 
 
 
 
 
 
 
 
 
2887
  "@types/parse-json": {
2888
  "version": "4.0.0",
2889
  "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz",
@@ -3739,6 +3777,18 @@
3739
  "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==",
3740
  "dev": true
3741
  },
 
 
 
 
 
 
 
 
 
 
 
 
3742
  "lodash.merge": {
3743
  "version": "4.6.2",
3744
  "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
 
10
  "devDependencies": {
11
  "@sveltejs/adapter-static": "^1.0.0-next.28",
12
  "@sveltejs/kit": "next",
13
+ "@tailwindcss/typography": "^0.5.2",
14
  "autoprefixer": "^10.4.2",
15
  "eslint": "^7.32.0",
16
  "eslint-config-prettier": "^8.3.0",
 
268
  }
269
  }
270
  },
271
+ "node_modules/@tailwindcss/typography": {
272
+ "version": "0.5.2",
273
+ "resolved": "https://registry.npmjs.org/@tailwindcss/typography/-/typography-0.5.2.tgz",
274
+ "integrity": "sha512-coq8DBABRPFcVhVIk6IbKyyHUt7YTEC/C992tatFB+yEx5WGBQrCgsSFjxHUr8AWXphWckadVJbominEduYBqw==",
275
+ "dev": true,
276
+ "dependencies": {
277
+ "lodash.castarray": "^4.4.0",
278
+ "lodash.isplainobject": "^4.0.6",
279
+ "lodash.merge": "^4.6.2"
280
+ },
281
+ "peerDependencies": {
282
+ "tailwindcss": ">=3.0.0 || >= 3.0.0-alpha.1 || insiders"
283
+ }
284
+ },
285
  "node_modules/@types/parse-json": {
286
  "version": "4.0.0",
287
  "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz",
 
1435
  "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==",
1436
  "dev": true
1437
  },
1438
+ "node_modules/lodash.castarray": {
1439
+ "version": "4.4.0",
1440
+ "resolved": "https://registry.npmjs.org/lodash.castarray/-/lodash.castarray-4.4.0.tgz",
1441
+ "integrity": "sha1-wCUTUV4wna3dTCTGDP3c9ZdtkRU=",
1442
+ "dev": true
1443
+ },
1444
+ "node_modules/lodash.isplainobject": {
1445
+ "version": "4.0.6",
1446
+ "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
1447
+ "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=",
1448
+ "dev": true
1449
+ },
1450
  "node_modules/lodash.merge": {
1451
  "version": "4.6.2",
1452
  "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
 
2911
  "svelte-hmr": "^0.14.9"
2912
  }
2913
  },
2914
+ "@tailwindcss/typography": {
2915
+ "version": "0.5.2",
2916
+ "resolved": "https://registry.npmjs.org/@tailwindcss/typography/-/typography-0.5.2.tgz",
2917
+ "integrity": "sha512-coq8DBABRPFcVhVIk6IbKyyHUt7YTEC/C992tatFB+yEx5WGBQrCgsSFjxHUr8AWXphWckadVJbominEduYBqw==",
2918
+ "dev": true,
2919
+ "requires": {
2920
+ "lodash.castarray": "^4.4.0",
2921
+ "lodash.isplainobject": "^4.0.6",
2922
+ "lodash.merge": "^4.6.2"
2923
+ }
2924
+ },
2925
  "@types/parse-json": {
2926
  "version": "4.0.0",
2927
  "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz",
 
3777
  "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==",
3778
  "dev": true
3779
  },
3780
+ "lodash.castarray": {
3781
+ "version": "4.4.0",
3782
+ "resolved": "https://registry.npmjs.org/lodash.castarray/-/lodash.castarray-4.4.0.tgz",
3783
+ "integrity": "sha1-wCUTUV4wna3dTCTGDP3c9ZdtkRU=",
3784
+ "dev": true
3785
+ },
3786
+ "lodash.isplainobject": {
3787
+ "version": "4.0.6",
3788
+ "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
3789
+ "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=",
3790
+ "dev": true
3791
+ },
3792
  "lodash.merge": {
3793
  "version": "4.6.2",
3794
  "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
client/package.json CHANGED
@@ -12,6 +12,7 @@
12
  "devDependencies": {
13
  "@sveltejs/adapter-static": "^1.0.0-next.28",
14
  "@sveltejs/kit": "next",
 
15
  "autoprefixer": "^10.4.2",
16
  "eslint": "^7.32.0",
17
  "eslint-config-prettier": "^8.3.0",
 
12
  "devDependencies": {
13
  "@sveltejs/adapter-static": "^1.0.0-next.28",
14
  "@sveltejs/kit": "next",
15
+ "@tailwindcss/typography": "^0.5.2",
16
  "autoprefixer": "^10.4.2",
17
  "eslint": "^7.32.0",
18
  "eslint-config-prettier": "^8.3.0",
client/src/components/NewsBlock.svelte CHANGED
@@ -2,20 +2,26 @@
2
  export let feedEntry;
3
  </script>
4
 
5
- <div class="group grid grid-cols-1 sm:grid-cols-3">
6
  <div>
7
  {#if feedEntry.media_content}
8
- <a target="_blank" href={feedEntry.link}>
9
  <img
10
- class="w-full max-w-[15rem] md:max-w-md object-cover object-top aspect-[4/3]"
11
  src={feedEntry.media_content[0].url}
12
  alt={feedEntry.title}
13
  loading="lazy"
14
  />
15
  </a>
 
 
 
 
 
 
16
  {/if}
17
  </div>
18
- <div class="col-span-2 sm:pl-4">
19
  <div class="text-sm">
20
  Score:
21
  <span class="font-bold {feedEntry.sentiment > 0 ? 'text-emerald-600' : 'text-red-600'}">
@@ -23,10 +29,12 @@
23
  </span>
24
  </div>
25
 
26
- <a target="_blank" href={feedEntry.link}>
27
- <h2 class="text-2xl font-bold font-serif leading-tight">{feedEntry.title}</h2>
28
- <h4 class="text-sm font-bold leading-tight">By {feedEntry.author}</h4>
29
- <p class="py-3 max-w-prose leading-normal">{@html feedEntry.summary}</p>
 
 
30
  <!-- {#if feedEntry.tags}
31
  <div class="text-sm">
32
  {#each feedEntry.tags as tag}
 
2
  export let feedEntry;
3
  </script>
4
 
5
+ <div class="group grid grid-cols-1 sm:grid-cols-3">
6
  <div>
7
  {#if feedEntry.media_content}
8
+ <a target="_blank" href={feedEntry.link}>
9
  <img
10
+ class="hover:opacity-60 m-0 w-full max-w-[15rem] md:max-w-md object-cover object-top aspect-[4/3]"
11
  src={feedEntry.media_content[0].url}
12
  alt={feedEntry.title}
13
  loading="lazy"
14
  />
15
  </a>
16
+ {:else}
17
+ <a target="_blank" href={feedEntry.link}>
18
+ <div
19
+ class="hover:opacity-60 bg-gray-200 h-full w-full max-w-[15rem] md:max-w-md object-cover object-top aspect-[4/3]"
20
+ />
21
+ </a>
22
  {/if}
23
  </div>
24
+ <div class="col-span-2 sm:pl-4">
25
  <div class="text-sm">
26
  Score:
27
  <span class="font-bold {feedEntry.sentiment > 0 ? 'text-emerald-600' : 'text-red-600'}">
 
29
  </span>
30
  </div>
31
 
32
+ <a target="_blank" class="no-underline" href={feedEntry.link}>
33
+ <h2 class="m-0 font-serif leading-tight hover:opacity-50">{feedEntry.title}</h2>
34
+ <h5 class="mt-1 leading-tight {feedEntry.author ? 'visibile' : 'invisible'}">
35
+ By {feedEntry.author}
36
+ </h5>
37
+ <p class="prose max-w-prose leading-normal prose-gray">{@html feedEntry.summary}</p>
38
  <!-- {#if feedEntry.tags}
39
  <div class="text-sm">
40
  {#each feedEntry.tags as tag}
client/src/routes/index.svelte CHANGED
@@ -44,7 +44,7 @@
44
  }
45
  lastUpdate = new Date(predictions.last_update);
46
  predictions = predictions.entries.sort((a, b) => b.sentiment - a.sentiment);
47
- positiveOrder = true
48
  console.log(lastUpdate, predictions);
49
  }
50
 
@@ -56,12 +56,12 @@
56
  }
57
  </script>
58
 
59
- <div class="px-6 py-3 max-w-4xl mx-auto">
60
- <h1 class="text-4xl font-bold font-serif pt-5 leading-tight">The New York Times Homepage</h1>
61
- <h3 class="text-sm leading-tight pb-5 {lastUpdate ? 'visibile' : 'invisible'}">
62
  <b>Last Updated:</b>
63
  {lastUpdate ? lastUpdate.toLocaleString() : ''}
64
- </h3>
65
 
66
  <p class="py-3 max-w-prose leading-normal">
67
  This project is an experiment running sentiment analysis on the current
@@ -99,12 +99,37 @@
99
  </p>
100
  <details>
101
  <summary class="cursor-pointer">Notes</summary>
102
- <p />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  </details>
104
 
105
- <p class="py-3 max-w-prose leading-normal">
106
  You can try other news feeds <select
107
- class="inline-block text-sm bg-gray-200 border border-gray-200 text-gray-700 px-1 py-1 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
108
  bind:value={selectedFeedUrl}
109
  >
110
  {#each feeds as feed (feed.value)}
@@ -130,7 +155,7 @@
130
  Loading the NYTimes homepage feed and running sentiment analysis on headlines...
131
  </div>
132
  {:then data}
133
- <ul>
134
  {#each predictions as entry, i}
135
  <li class="py-5">
136
  <NewsBlock feedEntry={entry} />
@@ -141,4 +166,4 @@
141
  {:catch error}
142
  <p>An error occurred!</p>
143
  {/await}
144
- </div>
 
44
  }
45
  lastUpdate = new Date(predictions.last_update);
46
  predictions = predictions.entries.sort((a, b) => b.sentiment - a.sentiment);
47
+ positiveOrder = true;
48
  console.log(lastUpdate, predictions);
49
  }
50
 
 
56
  }
57
  </script>
58
 
59
+ <article class="prose px-6 py-3 max-w-4xl mx-auto">
60
+ <h1 class="font-serif mb-0">The New York Times Homepage</h1>
61
+ <h5 class="mt-0 {lastUpdate ? 'visibile' : 'invisible'}">
62
  <b>Last Updated:</b>
63
  {lastUpdate ? lastUpdate.toLocaleString() : ''}
64
+ </h5>
65
 
66
  <p class="py-3 max-w-prose leading-normal">
67
  This project is an experiment running sentiment analysis on the current
 
99
  </p>
100
  <details>
101
  <summary class="cursor-pointer">Notes</summary>
102
+ <h4>Install Node with NVM</h4>
103
+ <p class="max-w-prose leading-normal">
104
+ This <a
105
+ class="text-blue-500 underline hover:no-underline"
106
+ target="_blank"
107
+ href="https://huggingface.co/spaces/radames/NYTimes-homepage-rearranged/blob/main/install-node.sh"
108
+ >Node script</a
109
+ >
110
+
111
+ install node LTS and create symbolic links to <code>/home/user/.local/bin/</code> as it seems like we don't
112
+ have permission to update $PATH env
113
+ </p>
114
+ <h4>main.py</h4>
115
+ <p class="max-w-prose leading-normal">
116
+ Because the Spaces run a python application, see "app_file" on docs. main.py is just a simple
117
+ python subprocess to make make", "build-all Makefile
118
+ https://huggingface.co/spaces/radames/NYTimes-homepage-rearranged/blob/main/Makefile
119
+ </p>
120
+ <h4>SvelteKit Node Adapter?</h4>
121
+ <p class="max-w-prose leading-normal">
122
+ SvelteKit eventually can be used as our primary web application with the
123
+ @sveltejs/adapter-node with Node and Flask the API application with your ML project. However,
124
+ there is an open issue to enable dynamic basepath, which blocks the possibility to embedded
125
+ deployment or relative path. https://github.com/sveltejs/kit/issues/595
126
+ https://huggingface.co/spaces/radames/NYTimes-homepage-rearranged/blob/main/main.py
127
+ </p>
128
  </details>
129
 
130
+ <p class="max-w-prose leading-normal">
131
  You can try other news feeds <select
132
+ class="inline-block text-xs bg-gray-200 border border-gray-200 text-gray-700 px-0 py-0 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
133
  bind:value={selectedFeedUrl}
134
  >
135
  {#each feeds as feed (feed.value)}
 
155
  Loading the NYTimes homepage feed and running sentiment analysis on headlines...
156
  </div>
157
  {:then data}
158
+ <ul class="m-0 p-0">
159
  {#each predictions as entry, i}
160
  <li class="py-5">
161
  <NewsBlock feedEntry={entry} />
 
166
  {:catch error}
167
  <p>An error occurred!</p>
168
  {/await}
169
+ </article>
client/tailwind.config.cjs CHANGED
@@ -3,5 +3,5 @@ module.exports = {
3
  theme: {
4
  extend: {}
5
  },
6
- plugins: []
7
  };
 
3
  theme: {
4
  extend: {}
5
  },
6
+ plugins: [require('@tailwindcss/typography')]
7
  };