Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Community page #874

Merged
merged 102 commits into from
Feb 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
335a8c8
Initial commit for community page
iAdramelk Dec 13, 2019
e03dc91
Add styles to community page blocks
iAdramelk Dec 16, 2019
8c560e6
Addicons to meet blocks
iAdramelk Dec 17, 2019
eb8477d
Remove console.log
iAdramelk Dec 17, 2019
08dc1bb
Add styles to Discord block
iAdramelk Dec 17, 2019
2f7f6be
Add styles for events
iAdramelk Dec 17, 2019
aadab00
Add illustration to community blocks
iAdramelk Dec 17, 2019
f066ee3
Add real github api for issues
iAdramelk Dec 17, 2019
c47c622
Add comment about Github API mock
iAdramelk Dec 17, 2019
b516a67
Move @octokit/graphql to dependencies
iAdramelk Dec 18, 2019
3f5ce01
Add blog api integration
iAdramelk Dec 18, 2019
bc7292e
Real API to get latest blog posts
iAdramelk Dec 18, 2019
19a44c5
Update texts
iAdramelk Dec 19, 2019
5813fb5
Add pluralization to comments count
iAdramelk Dec 19, 2019
e231d65
Add comments to blog posts
iAdramelk Dec 19, 2019
62bb8fa
Cache test
iAdramelk Dec 23, 2019
795e922
Rewrote comments API using fetch
iAdramelk Dec 23, 2019
2fc2d6a
Only show console.log in cache in dev mode
iAdramelk Dec 23, 2019
8b31260
Add cache to github
iAdramelk Dec 23, 2019
da51749
Replace Discord with widget
iAdramelk Dec 23, 2019
9532d3b
Hide events block if there is no upcoming events
iAdramelk Dec 23, 2019
7444f75
Add simple fallback for api handles
iAdramelk Dec 23, 2019
64477ff
Mobile version design
iAdramelk Dec 25, 2019
3e50505
Add dropdown menu to contribute
iAdramelk Dec 25, 2019
d10481f
Mobile design tweaks
iAdramelk Dec 26, 2019
eaf06f3
Fix comments height
iAdramelk Dec 26, 2019
b1c76bc
Revert discord widget
iAdramelk Jan 8, 2020
04922f6
Get discord stats from static file
iAdramelk Jan 8, 2020
b03df66
Merge branch 'revert-import-sort' into community-page
iAdramelk Jan 15, 2020
9e31267
Return deleted images
iAdramelk Jan 16, 2020
7da24be
Revert "Mobile design tweaks"
iAdramelk Jan 16, 2020
6a988c2
Mobile styles for section in community
iAdramelk Jan 16, 2020
af7e0f3
Small design changes
iAdramelk Jan 20, 2020
7ba0c16
Fix lint-staged bug
iAdramelk Jan 20, 2020
95f93b8
Add carousel to community page
iAdramelk Jan 21, 2020
439d48a
Fix lint error
iAdramelk Jan 21, 2020
eaaddb7
Add images to blog posts
iAdramelk Jan 22, 2020
7f80032
Add mobile banner
iAdramelk Jan 28, 2020
b6169a3
Make all mobile section parts clickable
iAdramelk Jan 28, 2020
1a8406c
Fix forum posts display on desktop
iAdramelk Jan 28, 2020
4186cc7
Remove focus state from carousel dots
iAdramelk Jan 28, 2020
b1b3f8d
Temporarily disable carousel
iAdramelk Jan 29, 2020
c954e9b
Add small visual fixes
iAdramelk Jan 29, 2020
2089bee
Fix mobile safari bug
iAdramelk Jan 29, 2020
88d017f
Update desktop dropdown styles
iAdramelk Jan 29, 2020
23087af
Remove carousel
iAdramelk Jan 29, 2020
3880429
Add pictures to user content
iAdramelk Jan 29, 2020
026679b
Add quick and dirty fix for section animation
iAdramelk Jan 30, 2020
ffd87ef
Added some user content
elleobrien Jan 30, 2020
7d0c4f9
three pieces of user content
elleobrien Jan 30, 2020
578ff63
added the prague event, cleaned up events city + date formatting
natikgadzhi Jan 30, 2020
15cb5b8
Added WIDS event
elleobrien Jan 30, 2020
207b65a
Added WIDS event
elleobrien Jan 30, 2020
439c008
WIDS logo
elleobrien Jan 30, 2020
d89a933
Added divops.org
natikgadzhi Jan 30, 2020
e8e02b3
Fixed divops date, and checked if the banners work as expected
natikgadzhi Jan 30, 2020
5db0313
typo
natikgadzhi Jan 30, 2020
4829e97
Added readable date support
iAdramelk Jan 31, 2020
920f159
Change rel for external links to correct one
iAdramelk Jan 31, 2020
db8b708
Update Cotribute section actions
iAdramelk Jan 31, 2020
5b3b9b8
Fix menu title
iAdramelk Jan 31, 2020
68d586a
Replace icons
iAdramelk Jan 31, 2020
026c218
Fix non-even columns
iAdramelk Feb 3, 2020
2431350
Add json linters
iAdramelk Feb 3, 2020
9c00cba
Add paddings for sections on tablets
iAdramelk Feb 3, 2020
a107990
Fix lint errors
iAdramelk Feb 3, 2020
735b32e
Update banner for Feb 20
elleobrien Feb 3, 2020
4ba5568
Added image icons to user content
elleobrien Feb 3, 2020
a34aa29
increase banner resolution
elleobrien Feb 4, 2020
8adf0e8
Fix links and add analytics to community page
iAdramelk Feb 4, 2020
eba68f0
Remove Learn section icons
iAdramelk Feb 4, 2020
51aef30
Normalize event pictures
iAdramelk Feb 4, 2020
6515583
Add placeholder for events images
iAdramelk Feb 4, 2020
57f367f
Fix image line wrap
iAdramelk Feb 4, 2020
403a922
Fix preemptive sendind of errors
iAdramelk Feb 5, 2020
f45e1bf
Add ref forwarding to button
iAdramelk Feb 5, 2020
7dab9bb
Merge remote-tracking branch 'origin/master' into community-page
iAdramelk Feb 5, 2020
c63bd7e
Update top menu styles (no-triangle)
iAdramelk Feb 6, 2020
9696da2
Update movile menu
iAdramelk Feb 6, 2020
047b8ad
Add github and discord icons to header
iAdramelk Feb 6, 2020
07bf5d0
Fix opacity for links
iAdramelk Feb 6, 2020
180af57
Make community headers clickable
iAdramelk Feb 6, 2020
6d27668
Fix Collapsible calculation on resize
iAdramelk Feb 6, 2020
44503b2
Open section on mobile navigation
iAdramelk Feb 6, 2020
52b753d
Reduce size of the icons in the head
iAdramelk Feb 7, 2020
a76e4fd
Fix bug woth bottom pading on tablet in Communuty
iAdramelk Feb 7, 2020
23771aa
Add triangle to dropdown menu
iAdramelk Feb 7, 2020
39c8799
Add subjects to mail links
iAdramelk Feb 10, 2020
62dcaf1
Merge remote-tracking branch 'origin/master' into community-page
iAdramelk Feb 11, 2020
6982960
Revert issues sorting order
iAdramelk Feb 11, 2020
46236b5
Open mail links in the new window
iAdramelk Feb 11, 2020
d2408d1
Set correct icon to mail in mobile menu
iAdramelk Feb 11, 2020
cba8d9b
Fix not working links in top menu
iAdramelk Feb 11, 2020
cb59ac6
update hero banners
shcheklein Feb 11, 2020
2aa9a6d
Merge branch 'community-page' of github.com:iterative/dvc.org into co…
shcheklein Feb 11, 2020
2fc731e
Fix item collapse in mobile safari
iAdramelk Feb 11, 2020
1412fe8
Fix couple of visual bugs
iAdramelk Feb 11, 2020
7917d66
Refactor Community page in line with other pages
iAdramelk Feb 11, 2020
4a4ce39
Change blog api error status to 502
iAdramelk Feb 11, 2020
a07117e
Rename BareButton to CommunityButton
iAdramelk Feb 11, 2020
306ff6c
Remove mistakenly copied images
iAdramelk Feb 12, 2020
451a2cc
Remove getInitialProps to reenable static optimizations
iAdramelk Feb 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ Sentry.init({
})

class MyApp extends App {
static async getInitialProps({ Component, ctx }) {
let pageProps = {}

if (Component.getInitialProps) {
pageProps = await Component.getInitialProps(ctx)
}

return { pageProps }
}

componentDidCatch(error, errorInfo) {
Sentry.withScope(scope => {
Object.keys(errorInfo).forEach(key => {
Expand Down
19 changes: 19 additions & 0 deletions pages/api/blog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import fetch from 'isomorphic-fetch'

export default async (_, res) => {
try {
const response = await fetch(`https://blog.dvc.org/api/posts.json`)

if (response.status !== 200) {
res.status(502).json({ error: 'Unexpected response from Blog' })

return
}

const data = await response.text()

res.status(200).json(data)
} catch {
res.status(502)
}
}
39 changes: 31 additions & 8 deletions pages/api/comments.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-env node */

/*
* This API endpoint is used by our blog to get comments count for the post, it
* gets discuss.dvc.org topic URL as a param and returns comments count or
Expand All @@ -7,17 +9,22 @@
* potential ability to cache comments count in the future.
*/

import fetch from 'isomorphic-fetch'
import Cors from 'micro-cors'
import request from 'request'
import NodeCache from 'node-cache'

import { BLOG_URL, FORUM_URL } from '../../src/consts'

const cache = new NodeCache({ stdTTL: 900 })

const dev = process.env.NODE_ENV === 'development'

const cors = Cors({
allowedMethods: ['GET', 'HEAD'],
origin: BLOG_URL
})

const getCommentCount = (req, res) => {
const getCommentCount = async (req, res) => {
const {
query: { url }
} = req
Expand All @@ -28,26 +35,42 @@ const getCommentCount = (req, res) => {
return
}

request(`${url}.json`, (error, response, body) => {
if (error || response.statusCode !== 200) {
if (cache.get(url) !== undefined) {
if (dev) console.log(`Using cache for ${url}`)

res.status(200).json({ count: cache.get(url) })

return
} else {
if (dev) console.log(`Not using cache for ${url}`)
}

try {
const response = await fetch(`${url}.json`)

if (response.status !== 200) {
res.status(502).json({ error: 'Unexpected response from Forum' })

return
}

const json = JSON.parse(body)
const data = await response.json()

if (!json.posts_count) {
if (!data.posts_count) {
res.status(502).json({ error: 'Unexpected payload from Forum' })

return
}

// post_count return all posts including topic itself
const count = json.posts_count - 1
const count = data.posts_count - 1

cache.set(url, count)

res.status(200).json({ count })
})
} catch {
res.status(404)
}
}

export default cors(getCommentCount)
51 changes: 51 additions & 0 deletions pages/api/discourse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* eslint-env node */

import fetch from 'isomorphic-fetch'
import NodeCache from 'node-cache'

import { FORUM_URL } from '../../src/consts'

const cache = new NodeCache({ stdTTL: 900 })

const dev = process.env.NODE_ENV === 'development'

export default async (_, res) => {
if (cache.get('topics')) {
if (dev) console.log('Using cache for "topics"')

res.status(200).json(cache.get('topics'))

return
} else {
if (dev) console.log('Not using cache for "topics"')
}

try {
const response = await fetch(`${FORUM_URL}/latest.json?order=created`)

if (response.status !== 200) {
res.status(502).json({ error: 'Unexpected response from Forum' })

return
}

const data = await response.text()

const {
topic_list: { topics: original_topics }
} = JSON.parse(data)

const topics = original_topics.slice(0, 3).map(item => ({
title: item.title,
comments: item.posts_count - 1,
date: item.last_posted_at,
url: `${FORUM_URL}/t/${item.slug}/${item.id}`
}))

cache.set('topics', { topics })

res.status(200).json({ topics })
} catch {
res.status(404)
}
}
67 changes: 67 additions & 0 deletions pages/api/github.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* eslint-env node */

import { graphql } from '@octokit/graphql'
import NodeCache from 'node-cache'

const cache = new NodeCache({ stdTTL: 900 })

const dev = process.env.NODE_ENV === 'development'

export default async (_, res) => {
if (!process.env.GITHUB_TOKEN) {
res.status(200).json({ issues: [] })
} else {
if (cache.get('issues')) {
if (dev) console.log('Using cache for "issues"')

res.status(200).json({ issues: cache.get('issues') })
} else {
console.log('Not using cache for "issues"')
}

try {
const { repository } = await graphql(
`
{
repository(owner: "iterative", name: "dvc") {
issues(
first: 3
states: OPEN
orderBy: { field: CREATED_AT, direction: DESC }
) {
edges {
node {
title
createdAt
url
comments {
totalCount
}
}
}
}
}
}
`,
{
headers: {
authorization: `token ${process.env.GITHUB_TOKEN}`
}
}
)

const issues = repository.issues.edges.map(({ node }) => ({
title: node.title,
url: node.url,
comments: node.comments.totalCount,
date: node.createdAt
}))

cache.set('issues', issues)

res.status(200).json({ issues })
} catch (e) {
res.status(404)
}
}
}
46 changes: 46 additions & 0 deletions pages/community.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react'
import Head from 'next/head'

import {
getLatestIssues,
getLatestTopics,
getLatestPosts
} from '../src/utils/api'

import Community from '../src/components/Community'

import { META_BASE_TITLE } from '../src/consts'

export default function CommunityPage(props) {
return (
<>
<Head>
<link
rel="stylesheet"
type="text/css"
charSet="UTF-8"
href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css"
/>
<link
rel="stylesheet"
type="text/css"
href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick-theme.min.css"
/>
<title>Community | {META_BASE_TITLE}</title>
</Head>
<Community {...props} />
</>
)
}

CommunityPage.getInitialProps = async ({ req }) => {
const issues = await getLatestIssues(req)
const posts = await getLatestPosts(req)
const topics = await getLatestTopics(req)

return {
issues,
posts,
topics
}
}
Loading