Comienzo de nueva version de la pagina de inicio

This commit is contained in:
2021-12-16 00:17:07 -03:00
parent 853cfa5da3
commit 8ac3179b35
26 changed files with 7301 additions and 155 deletions

18
src/App.svelte Normal file
View File

@@ -0,0 +1,18 @@
<script>
import Search from "./Search.svelte";
import LinkGroup from "./LinkGroup.svelte";
import Container from "./Container.svelte";
import {groups} from "./store";
</script>
<Container>
<Search slot="search"/>
<svelte:fragment slot="groups">
{#each $groups as group}
<LinkGroup group="{group}"/>
{/each}
</svelte:fragment>
</Container>

8
src/Container.svelte Normal file
View File

@@ -0,0 +1,8 @@
<div class="h-screen w-screen flex items-center justify-center">
<div class="flex flex-col w-full max-w-screen-md p-2 space-y-2">
<slot name="search"/>
<div class="grid grid-cols-[10ch_auto] p-2">
<slot name="groups"/>
</div>
</div>
</div>

11
src/Link.svelte Normal file
View File

@@ -0,0 +1,11 @@
<script>
export let link;
</script>
<a
href="{link.href}"
referrerpolicy="no-referrer"
class="cursor-pointer hover:underline"
>
[{link.name}]
</a>

15
src/LinkGroup.svelte Normal file
View File

@@ -0,0 +1,15 @@
<script>
import Link from "./Link.svelte";
export let group = {
name: '',
links: []
};
</script>
<span class="font-bold">{group.name}</span>
<div class="space-x-3">
{#each group.links as link}
<Link link="{link}"/>
{/each}
</div>

38
src/Search.svelte Normal file
View File

@@ -0,0 +1,38 @@
<script>
let search = '';
function doNavigation(url) {
if(
url.slice(0,7) === 'http://' ||
url.slice(0,8) === 'https://' ||
url.slice(0,2) === '//'
){
window.location.href=url;
} else {
window.location.href=`//${url}`;
}
}
function doSearch(term) {
doNavigation(`https://duckduckgo.com/?q=${term}`);
}
function submit(event) {
if(event.key !== 'Enter') return;
if(search.trim() === '') return;
if(event.composed && event.ctrlKey){
doNavigation(search);
}else{
doSearch(search);
}
}
</script>
<input
type="search"
autocomplete="false"
bind:value={search}
on:keyup|preventDefault={submit}
class="border-2 border-black py-2 px-2"
/>

5
src/main.js Normal file
View File

@@ -0,0 +1,5 @@
import App from './App.svelte';
const app = new App({target: document.body});
export default app;

43
src/store.js Normal file
View File

@@ -0,0 +1,43 @@
import {readable} from "svelte/store";
const defaultGroups = [
{
name: 'General',
links: [
{name: 'twitter', link: 'https://twitter.com'},
{name: 'youtube', link: 'https://youtube.com'},
{name: 'hacker_news', link: 'https://news.ycombinator.com'},
{name: 'lobsters', link: 'https://lobste.rs'},
{name: 'whatsapp', link: 'https://web.whatsapp.com'},
]
},
{
name: 'Inacap',
links: [
{name: 'home', link: 'https://www.inacap.cl/'},
{name: 'intranet', link: 'https://adfs.inacap.cl/adfs/ls/?wtrealm=https://siga.inacap.cl/sts/&wa=wsignin1.0&wreply=https://siga.inacap.cl/sts/&wctx=https%3a%2f%2fadfs.inacap.cl%2fadfs%2fls%2f%3fwreply%3dhttps%3a%2f%2fwww.inacap.cl%2ftportalvp%2fintranet-alumno%26wtrealm%3dhttps%3a%2f%2fwww.inacap.cl%2f'},
{name: 'aprendizaje', link: 'https://www.inacap.cl/tportalvp/procesar_link.php?url=https://lms.inacap.cl/auth/saml2/login.php?wants=https://lms.inacap.cl/my/'},
]
},
{
name: 'Reddit',
links: [
{name: 'frontpage', link: 'https://reddit.com'},
{name: 'r/unixporn', link: 'https://reddit.com/r/unixporn'},
{name: 'r/piracy', link: 'https://reddit.com/r/piracy'},
{name: 'r/roms', link: 'https://reddit.com/r/roms'},
{name: 'r/chile', link: 'https://reddit.com/r/chile'},
]
},
{
name: '4chan',
links: [
{name: '/g/', link: 'https://4chan.org/g/catalog'},
{name: '/wg/', link: 'https://4chan.org/wg/catalog'},
{name: '/v/', link: 'https://4chan.org/v/catalog'},
{name: '/x/', link: 'https://4chan.org/x/catalog'},
]
},
]
export const groups = readable(defaultGroups, () => {}, ()=>{})