Skip to content

Commit

Permalink
ANW2-18 replace airtable with feeds api and link logo to homepage
Browse files Browse the repository at this point in the history
Signed-off-by: Greg Osuri <[email protected]>
  • Loading branch information
gosuri committed Jul 29, 2022
1 parent 596cbf3 commit 9adf675
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .akash/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1658277144
1658953195
37 changes: 37 additions & 0 deletions .akash/cache/sdl.1658953195.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
deployment:
web:
dcloud:
count: 1
profile: web
profiles:
compute:
web:
resources:
cpu:
units: 0.5
memory:
size: 512Mi
storage:
size: 512Mi
placement:
dcloud:
attributes:
host: akash
pricing:
web:
amount: 1000
denom: uakt
signedBy:
anyOf:
- akash1365yvmc4s7awdyj3n2sav7xfx76adc6dnmlx63
services:
web:
expose:
- accept:
- ecosystem.akash.network
as: 80
port: 3000
to:
- global: true
image: ghcr.io/gosuri/akash-ecosystem:1658953195
version: "2.0"
68 changes: 14 additions & 54 deletions lib/projects.js
Original file line number Diff line number Diff line change
@@ -1,75 +1,35 @@
import { useState } from "react";
import cacheData from "memory-cache";
const ecosystemEndpoint = "http://feeds.akash.network/ecosystem";

const endpoint = "https://api.airtable.com/v0/appHcQU9gd0RCCeJS";
const apikey = "keyZLM4ZzL3PgPQyQ"; // Readonly Key as Artable lacks support for public APIs. Dont get cute ideas.

const projectsEndpoint = `${endpoint}/Projects?api_key=${apikey}`;
const tweetsEndpoint = `${endpoint}/Tweets?api_key=${apikey}`;
const videosEndpoint = `${endpoint}/Videos?api_key=${apikey}`;


function makeProject(record) {
let name = record.fields["Name"];
let id = name.trim().toLowerCase().replaceAll(' ', '-');
let category = record.fields["Category"];
let description = record.fields["Description"];
let logo_square = `https://picsum.photos/seed/${category}/400/400`;

if (record.fields["Logo Square"].length > 0 ) {
logo_square = record.fields["Logo Square"][0].url;
}

return {
id: id,
name: name,
category: category,
logo_square: logo_square,
description: description,
export async function getEcosystemData() {
let response = await fetch(ecosystemEndpoint);
let data = await response.json();
if (data && data["projects"].length > 0) {
return data["projects"]
}
}

export async function getProjectsData() {
var projects = cacheData.get("projects");
if (projects == undefined) {
console.log("projects is null")
projects = [];
}
console.log("projects.length: ", projects.length)

if (projects.length > 0) { return projects };
console.log("fetching: " + projectsEndpoint);
const res = await fetch(projectsEndpoint);
const data = await res.json();
//console.log(data.records);
data.records.map((record) => {
projects.push(makeProject(record))
});
//console.log(projects)
cacheData.put("projects", projects);
return projects;
}

export async function getProjectIDs() {
const dat = await getProjectsData();
const dat = await getEcosystemData();
return dat.map((item) => {
return {
params: {
id: item.id,
id: item.slug,
},
};
});
}

export async function getProjectData(id) {
const dat = await getProjectsData();
export async function getProjectData(slug) {
const dat = await getEcosystemData();
let result = "";
dat.map((item) => {
if (item.id === id) {
result = item
dat.map((project) => {
if (project.slug === slug) {
result = project
return
}
});
console.log("getting project: " + result.name)
console.log("fetching project: " + result.name)
return result;
}
18 changes: 10 additions & 8 deletions pages/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Head from 'next/head'
import Image from 'next/image'
import Link from 'next/link'
import { getProjectsData } from '../lib/projects';
import { getEcosystemData } from '../lib/projects';

export async function getStaticProps() {
const allProjectsData = await getProjectsData();
const allProjectsData = await getEcosystemData();
return { props: { allProjectsData }
};
}
Expand Down Expand Up @@ -33,7 +33,9 @@ export default function Home({ allProjectsData }) {
<div className="max-w-7xl mx-auto py-16 px-4 sm:py-24 sm:px-6 lg:px-8">
<div className="text-center">
<div className="text-base font-semibold text-indigo-600 tracking-wide uppercase">
<Image src="/images/akash-red.svg" width="100" height="100"></Image>
<a href="https://akash.network">
<Image src="/images/akash-red.svg" width="100" height="100"></Image>
</a>
</div>
<p className="mt-1 text-4xl font-extrabold text-gray-900 sm:text-5xl sm:tracking-tight lg:text-7xl">
Akash Ecosystem
Expand All @@ -46,9 +48,9 @@ export default function Home({ allProjectsData }) {
</div>
<ul role="list" className="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3">
{allProjectsData.map((item) =>
<li key={item.id} className="col-span-1 bg-white rounded-lg shadow divide-y divide-gray-200">
{/* <Link href={`/projects/${item.id}`}>
<a> */}
<li key={item.slug} className="col-span-1 bg-white rounded-lg shadow divide-y divide-gray-200">
{/* <Link href={`/projects/${item.slug}`}> */}
<a>
<div className="w-full flex items-center justify-left p-6 space-x-6">
<img className="w-20 h-20 bg-gray-300 rounded-lg" src={item.logo_square}></img>
<div className='className="flex-1 truncate"'>
Expand All @@ -59,8 +61,8 @@ export default function Home({ allProjectsData }) {
<p className="mt-1 text-gray-500 text-sm">{item.description}</p>
</div>
</div>
{/* </a>
</Link> */}
</a>
{/* </Link> */}
</li>
)}
</ul>
Expand Down
16 changes: 14 additions & 2 deletions pages/projects/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ export async function getStaticProps({ params }) {

export default function Project({ prjData }) {
return (
<h1>{ prjData.name }</h1>
)
<div className="container mx-auto">
<div className="flex flex-col items-center justify-center">
<h1 className="text-3xl font-bold text-center">{prjData.name}</h1>
<div className="flex flex-col items-center justify-center">
<img src={prjData.logo_square} alt={prjData.name} className="w-full" />
<div className="text-center">
<a href={prjData.url} className="text-blue-500 underline">
{prjData.url}
</a>
</div>
</div>
</div>
</div>
);
}

0 comments on commit 9adf675

Please sign in to comment.