From cd9b802b71df4e2701e2311b2995fe70a9692ae4 Mon Sep 17 00:00:00 2001 From: Renard Date: Mon, 16 Sep 2019 01:22:56 -0300 Subject: Prettier --- src/Api.js | 20 ++--- src/App.css | 8 +- src/App.js | 54 ++++++++----- src/Board.js | 176 +++++++++++++++++++++++------------------- src/Home.js | 227 ++++++++++++++++++++++++++++++++----------------------- src/NotFound.js | 24 +++--- src/Post.js | 159 ++++++++++++++++++++++++-------------- src/Quotes.js | 190 +++++++++++++++++++++++++++++++++++++++++++++- src/ReplyForm.js | 187 +++++++++++++++++++++++++-------------------- src/Thread.js | 171 +++++++++++++++++++++++------------------ src/index.html | 18 ++--- 11 files changed, 801 insertions(+), 433 deletions(-) (limited to 'src') diff --git a/src/Api.js b/src/Api.js index b564aa2..3999b7a 100644 --- a/src/Api.js +++ b/src/Api.js @@ -1,13 +1,15 @@ async function getBoards() { - var ret = await fetch("https://bienvenidoainternet.org/cgi/api/boards") - .then((response) => { - return response.json(); - }).then((resource) => { - //console.log(resource["boards"]); - return resource["boards"]; - }).catch(console.error) + var ret = await fetch("https://bienvenidoainternet.org/cgi/api/boards") + .then(response => { + return response.json(); + }) + .then(resource => { + //console.log(resource["boards"]); + return resource["boards"]; + }) + .catch(console.error); - return ret; + return ret; } -export default getBoards; \ No newline at end of file +export default getBoards; diff --git a/src/App.css b/src/App.css index 16aba4d..3b800da 100644 --- a/src/App.css +++ b/src/App.css @@ -19,7 +19,7 @@ } .vipFont { - font-family: Mona, Monapo, IPAMonaPGothic, 'MS PGothic', YOzFontAA97; + font-family: Mona, Monapo, IPAMonaPGothic, "MS PGothic", YOzFontAA97; } .tripcode { @@ -28,11 +28,11 @@ } .username { - color: #B5BD68; + color: #b5bd68; } .username.sage { - color: #81A2BE; + color: #81a2be; } /* a quien estás citando? */ @@ -77,4 +77,4 @@ .deleted { color: rgba(0, 0, 0, 0.4); font-style: italic; -} \ No newline at end of file +} diff --git a/src/App.js b/src/App.js index 99860cc..7b6bc94 100644 --- a/src/App.js +++ b/src/App.js @@ -1,14 +1,14 @@ -import React, { Component } from 'react'; +import React, { Component } from "react"; import { render } from "react-dom"; import { Router, Link } from "@reach/router"; -import 'fomantic-ui-css/semantic.css'; +import "fomantic-ui-css/semantic.css"; import "./App.css"; import { Dropdown, Menu, Icon, Loader, Container } from "semantic-ui-react"; import Home from "./Home"; import Thread from "./Thread"; import Board from "./Board"; -import NotFound from "./NotFound" +import NotFound from "./NotFound"; class App extends Component { constructor() { @@ -16,16 +16,15 @@ class App extends Component { this.state = { boardList: [], isLoaded: false - } - + }; } componentDidMount() { fetch("https://bienvenidoainternet.org/cgi/api/boards") - .then((response) => { + .then(response => { return response.json(); }) - .then((resource) => { + .then(resource => { this.setState({ boardList: resource["boards"], isLoaded: true }); }) .catch(console.error); @@ -37,8 +36,8 @@ class App extends Component { return ( Cargando ... - - ) + + ); } } @@ -49,15 +48,37 @@ class App extends Component { B.a.I - Home - + + Home + + - {boardList.map(board => board.board_type === 1 ? /{board.dir}/ - {board.name} : null)} + {boardList.map(board => + board.board_type === 1 ? ( + + /{board.dir}/ - {board.name} + + ) : null + )} - + - {boardList.map(board => board.board_type === 0 ? /{board.dir}/ - {board.name} : null)} + {boardList.map(board => + board.board_type === 0 ? ( + + /{board.dir}/ - {board.name} + + ) : null + )} @@ -71,11 +92,10 @@ class App extends Component { - + ); } } - -render(, document.getElementById("root")); \ No newline at end of file +render(, document.getElementById("root")); diff --git a/src/Board.js b/src/Board.js index 11a2493..514687b 100644 --- a/src/Board.js +++ b/src/Board.js @@ -1,92 +1,116 @@ import React, { Component } from "react"; -import { Loader, Message, Segment, Header, Image, Comment, Divider } from "semantic-ui-react"; +import { + Loader, + Message, + Segment, + Header, + Image, + Comment, + Divider +} from "semantic-ui-react"; import { Link } from "@reach/router"; import Moment from "react-moment"; import "moment/locale/es"; import Post from "./Post"; class Board extends Component { - constructor() { - super(); - this.state = { - isLoaded: false, - threadList: [], - error: null - } - } + constructor() { + super(); + this.state = { + isLoaded: false, + threadList: [], + error: null + }; + } - componentDidMount() { - fetch(`https://bienvenidoainternet.org/cgi/api/list?dir=${this.props.dir}&replies=5&limit=10`) - .then((response) => { - return response.json(); - }) - .then((resource) => { - if (resource["state"] === "error") { - this.setState({ error: resource }); - } - this.setState({ isLoaded: true, threadList: resource["threads"] }) - }) - .catch(console.error) - } + componentDidMount() { + fetch( + `https://bienvenidoainternet.org/cgi/api/list?dir=${this.props.dir}&replies=5&limit=10` + ) + .then(response => { + return response.json(); + }) + .then(resource => { + if (resource["state"] === "error") { + this.setState({ error: resource }); + } + this.setState({ isLoaded: true, threadList: resource["threads"] }); + }) + .catch(console.error); + } - componentWillUnmount() { - console.log("will unmount") - } + componentWillUnmount() { + console.log("will unmount"); + } - componentDidUpdate(prevProps) { - // Uso tipico (no olvides de comparar los props): - if (this.props.dir !== prevProps.dir) { - this.setState({ - isLoaded: false, - threadList: [], - error: null - }) - this.componentDidMount(); - } + componentDidUpdate(prevProps) { + // Uso tipico (no olvides de comparar los props): + if (this.props.dir !== prevProps.dir) { + this.setState({ + isLoaded: false, + threadList: [], + error: null + }); + this.componentDidMount(); } + } - render() { - const { isLoaded, error, threadList } = this.state; + render() { + const { isLoaded, error, threadList } = this.state; - if (error != null) { - return ( -
- - API Status: {error.state} -

{error.message}

-
-
- ); - } - - if (!isLoaded) { - return ( - - Cargando ... - - ) - } + if (error != null) { + return ( +
+ + API Status: {error.state} +

{error.message}

+
+
+ ); + } - return ( -
- {threadList.map(thread => - -
- {thread.subject} -
- - - - - {thread.replies.map((reply, index, replies) => - - )} - - -
- )} -
- ); + if (!isLoaded) { + return ( + + Cargando ... + + ); } + + return ( +
+ {threadList.map(thread => ( + +
+ + {thread.subject} + +
+ + + + + {thread.replies.map((reply, index, replies) => ( + + ))} + + +
+ ))} +
+ ); + } } -export default Board; \ No newline at end of file +export default Board; diff --git a/src/Home.js b/src/Home.js index 8493db2..4544cf2 100644 --- a/src/Home.js +++ b/src/Home.js @@ -6,105 +6,144 @@ import "moment/locale/es"; import { Link } from "@reach/router"; class Home extends Component { - constructor() { - super(); - this.state = { - lastAgeThreads: [], - newThreadsList: [], - latestNews: [], - isLoaded: false - } - } - - componentDidMount() { - fetch("https://bienvenidoainternet.org/cgi/api/lastage?limit=10") - .then((response) => { return response.json() }) - .then((resource) => { - this.setState({ - lastAgeThreads: resource["threads"] - }) - }); + constructor() { + super(); + this.state = { + lastAgeThreads: [], + newThreadsList: [], + latestNews: [], + isLoaded: false + }; + } - fetch("https://bienvenidoainternet.org/cgi/api/newThreads?limit=10") - .then((response) => { return response.json() }) - .then((resource) => { - this.setState({ - newThreadsList: resource["threads"], - }); - }); + componentDidMount() { + fetch("https://bienvenidoainternet.org/cgi/api/lastage?limit=10") + .then(response => { + return response.json(); + }) + .then(resource => { + this.setState({ + lastAgeThreads: resource["threads"] + }); + }); - fetch("https://bienvenidoainternet.org/cgi/api/blotter") - .then((response) => { return response.json() }) - .then((resource) => { - this.setState({ - latestNews: resource["news"], - isLoaded: true - }); - }); - } + fetch("https://bienvenidoainternet.org/cgi/api/newThreads?limit=10") + .then(response => { + return response.json(); + }) + .then(resource => { + this.setState({ + newThreadsList: resource["threads"] + }); + }); - render() { - if (!this.state.isLoaded) { - return ( - - Cargando ... - - ) - } + fetch("https://bienvenidoainternet.org/cgi/api/blotter") + .then(response => { + return response.json(); + }) + .then(resource => { + this.setState({ + latestNews: resource["news"], + isLoaded: true + }); + }); + } - const { newThreadsList, lastAgeThreads, latestNews } = this.state; + render() { + if (!this.state.isLoaded) { + return ( + + Cargando ... + + ); + } - return ( - - - -
Hilos activos
- - {lastAgeThreads.map(thread => - - - - {thread.content} - {thread.board_fulln} ― - - - )} - -
- -
Nuevos hilos
- - {newThreadsList.map(thread => - - - - {thread.content} - {thread.board_fulln} ― - - - )} - -
-
- - -
Blotter
- - {latestNews.map(n => - - -
- + const { newThreadsList, lastAgeThreads, latestNews } = this.state; - - - )} - - - - - ); - } + return ( + + + +
Hilos activos
+ + {lastAgeThreads.map(thread => ( + + + + + {thread.content} + + + {thread.board_fulln} ―{" "} + + + + + + ))} + +
+ +
Nuevos hilos
+ + {newThreadsList.map(thread => ( + + + + + {thread.content} + + + {thread.board_fulln} ―{" "} + + + + + + ))} + +
+
+ + +
Blotter
+ + {latestNews.map(n => ( + + +
+ + + + + + + ))} + + + + + ); + } } -export default Home; \ No newline at end of file +export default Home; diff --git a/src/NotFound.js b/src/NotFound.js index 8f04084..55ff50a 100644 --- a/src/NotFound.js +++ b/src/NotFound.js @@ -2,17 +2,15 @@ import React from "react"; import { Header, Icon } from "semantic-ui-react"; const NotFound = () => { - return ( -
-
- - 404 - - Recurso no encontrado - -
-
- ) -} + return ( +
+
+ + 404 + Recurso no encontrado +
+
+ ); +}; -export default NotFound; \ No newline at end of file +export default NotFound; diff --git a/src/Post.js b/src/Post.js index 3d08c05..4ccb7d0 100644 --- a/src/Post.js +++ b/src/Post.js @@ -1,69 +1,116 @@ import React from "react"; -import { Segment, Header, Image, Label, Icon, Modal, Comment, Divider } from "semantic-ui-react"; +import { + Segment, + Header, + Image, + Label, + Icon, + Modal, + Comment, + Divider +} from "semantic-ui-react"; import Moment from "react-moment"; import "moment/locale/es"; import { avatars } from "./Quotes"; const ImageModal = ({ href, trigger }) => ( - - - - - - - + + + + + + + ); const Post = ({ index, post, locked, dir, threadId }) => { - if (post.IS_DELETED > 0) { - return ( - - - - #{index + 1} - -
-
- - Eliminado por el {post.IS_DELETED === 1 ? "usuario." : "Staff."} - -
-
- ); - } + if (post.IS_DELETED > 0) { + return ( + + + + #{index + 1} + +
+ +
+
+ + + Eliminado por el {post.IS_DELETED === 1 ? "usuario." : "Staff."} + + +
+
+ ); + } - const filesize = require('filesize'); - const seedrandom = require("seedrandom"); - const rng = seedrandom(threadId + index); + const filesize = require("filesize"); + const seedrandom = require("seedrandom"); + const rng = seedrandom(threadId + index); - let user_id = post.timestamp_formatted.split(" ID:")[1]; - const i = Math.round(rng() * avatars.length); - const rndAvatar = avatars[i]; + let user_id = post.timestamp_formatted.split(" ID:")[1]; + const i = Math.round(rng() * avatars.length); + const rndAvatar = avatars[i]; - return ( - - - - #{index + 1} {post.name}{post.tripcode} - -
-
{user_id}
-
- - {post.file !== "" ? -
- } /> - {post.file} {post.image_width}x{post.image_height} {filesize(post.file_size, { bits: true })} -
- : null} -
- - - ResponderReportar - - - - ); -} + return ( + + + + + #{index + 1}{" "} + + {post.name} + + {post.tripcode} + + +
+ +
+
+ + {user_id} +
+
+ + {post.file !== "" ? ( +
+ + } + /> + {post.file} {post.image_width}x{post.image_height}{" "} + {filesize(post.file_size, { bits: true })} +
+ ) : null} +
+ + + Responder + Reportar + + + + ); +}; -export default Post; \ No newline at end of file +export default Post; diff --git a/src/Quotes.js b/src/Quotes.js index 07b538d..0b58349 100644 --- a/src/Quotes.js +++ b/src/Quotes.js @@ -1,2 +1,188 @@ -export const avatars = ["1372836", "6396408", "anime_charhan02", "anime_jyorujyu01", "anime_monar05", "anime_sasuga04", "anime_zonu01", "fuun", "gocchin_face", "iyou", "kuma", "nurupo_ga_2", "u_naoruyo_bath", "1k", "6za", "anime_giko01", "anime_jyorujyu02", "anime_morara01", "anime_shii01", "anime_zonu02", "gaku", "gomiopen", "jisakujien_2", "kuma2", "onigiri_seito", "u_okotowari_a", "2-1", "8028885", "anime_giko04", "anime_jyorujyu03", "anime_morara02", "anime_shii02", "aramaki", "gaku2", "goo_1", "jisakujien_xmas", "maimai", "otiketu48", "u_sofa", "2ppa", "8toushinnomonar16", "anime_giko10", "anime_kukkuru01", "anime_morara04", "anime_shii03", "aroeri-na32", "gaku3", "goo_3", "kantoku1", "makotan2_folder", "pc3", "wakannai1", "2syobo_2", "8toushinnomonar32", "anime_giko11", "anime_kuma01", "anime_nokar01", "anime_syobon01", "asopasomaso", "gekisya1", "gya-", "kappappa1", "mona", "pgya", "yakimochi", "3", "ace", "anime_giko12", "anime_kumaface01", "anime_okashi01", "anime_syobon03", "bikyakusan32", "giko1", "hagenin-shuriken", "kasa-ri", "mona_shiri", "sasuga1", "youkan", "3-2", "af1", "anime_giko13", "anime_loop", "anime_okashi02", "anime_tarn01", "bs", "gikog_gomibako", "hagurumaou", "kashiwamo-chi32", "mona_tya", "seito_2", "zonu_1", "3na", "af2", "anime_hossyu01", "anime_marara02", "anime_onigiri04", "anime_uwan01", "button1_03", "gikog_gyunyupack", "hikky", "kinokorusensei32", "monaazarashi_1", "soon", "zuzagiko48", "4-2", "ahya_xmas_2", "anime_imanouchi01", "anime_matanki01", "anime_saitama01", "anime_uwan02", "buun", "gikog_pimiento", "hikky_xmas_2", "kita_", "namaetukenai", "tasukete", "4248688", "aka", "anime_iyou02", "anime_matanki02", "anime_saitama02", "anime_uwan03", "chahan", "gikoinu", "hyou", "kodomona", "naoruyo", "torimasu1", "5007629", "ame", "anime_jien01", "anime_miruna01", "anime_saitama03", "anime_youkanman01", "dokuo1", "gikoneko", "iirasan_face", "konkon_folder", "nida", "torimasu2", "5296219", "anime_buun02", "anime_jien02", "anime_monar02", "anime_sasuga01", "anime_youkanman02", "file2_01", "gikoneko_1", "imanouchi_1", "kossorisan", "nigete", "u_ame", "5ta", "anime_charhan01", "anime_jien03", "anime_monar03", "anime_sasuga03", "anime_youkanman03", "fujisan", "gikoneko2", "iyahoo", "kotatu", "nono_ie", "u_hoshi"]; -export const quotes = ["Eres una buena persona.", "Y por invertir en felaciones.", "Fue un mensaje cachilupi.", "holiwi :3", "Hemos enviado a tu casa un ejército de prostitutas.", "Fue un mensaje de PURA CALIDAD.", "Ganaste frot gratis por una semana.", "Te besaría en la boca.", "Te invitaría a un café.", "ミト━━━━━━⊂( ゚ ヮ゚)⊃━━━━━━ン!!!!!", "Suenas como un bot muy desarrollado.", "¿Usaste TheSaurus para escribir tu post?", "(´・ω・`)", "Plataformas del futuro para la web 1.0.", "Gracias por utilizar Internet.", "Plataformas del pasado para la web 2.0.", "Elegiste bien. Elegiste calidad.", "Espero que no hayas abusado del sage.", "gRAciAs pOR Tu PAgA ;)", "Gracias por tu papiro."] \ No newline at end of file +export const avatars = [ + "1372836", + "6396408", + "anime_charhan02", + "anime_jyorujyu01", + "anime_monar05", + "anime_sasuga04", + "anime_zonu01", + "fuun", + "gocchin_face", + "iyou", + "kuma", + "nurupo_ga_2", + "u_naoruyo_bath", + "1k", + "6za", + "anime_giko01", + "anime_jyorujyu02", + "anime_morara01", + "anime_shii01", + "anime_zonu02", + "gaku", + "gomiopen", + "jisakujien_2", + "kuma2", + "onigiri_seito", + "u_okotowari_a", + "2-1", + "8028885", + "anime_giko04", + "anime_jyorujyu03", + "anime_morara02", + "anime_shii02", + "aramaki", + "gaku2", + "goo_1", + "jisakujien_xmas", + "maimai", + "otiketu48", + "u_sofa", + "2ppa", + "8toushinnomonar16", + "anime_giko10", + "anime_kukkuru01", + "anime_morara04", + "anime_shii03", + "aroeri-na32", + "gaku3", + "goo_3", + "kantoku1", + "makotan2_folder", + "pc3", + "wakannai1", + "2syobo_2", + "8toushinnomonar32", + "anime_giko11", + "anime_kuma01", + "anime_nokar01", + "anime_syobon01", + "asopasomaso", + "gekisya1", + "gya-", + "kappappa1", + "mona", + "pgya", + "yakimochi", + "3", + "ace", + "anime_giko12", + "anime_kumaface01", + "anime_okashi01", + "anime_syobon03", + "bikyakusan32", + "giko1", + "hagenin-shuriken", + "kasa-ri", + "mona_shiri", + "sasuga1", + "youkan", + "3-2", + "af1", + "anime_giko13", + "anime_loop", + "anime_okashi02", + "anime_tarn01", + "bs", + "gikog_gomibako", + "hagurumaou", + "kashiwamo-chi32", + "mona_tya", + "seito_2", + "zonu_1", + "3na", + "af2", + "anime_hossyu01", + "anime_marara02", + "anime_onigiri04", + "anime_uwan01", + "button1_03", + "gikog_gyunyupack", + "hikky", + "kinokorusensei32", + "monaazarashi_1", + "soon", + "zuzagiko48", + "4-2", + "ahya_xmas_2", + "anime_imanouchi01", + "anime_matanki01", + "anime_saitama01", + "anime_uwan02", + "buun", + "gikog_pimiento", + "hikky_xmas_2", + "kita_", + "namaetukenai", + "tasukete", + "4248688", + "aka", + "anime_iyou02", + "anime_matanki02", + "anime_saitama02", + "anime_uwan03", + "chahan", + "gikoinu", + "hyou", + "kodomona", + "naoruyo", + "torimasu1", + "5007629", + "ame", + "anime_jien01", + "anime_miruna01", + "anime_saitama03", + "anime_youkanman01", + "dokuo1", + "gikoneko", + "iirasan_face", + "konkon_folder", + "nida", + "torimasu2", + "5296219", + "anime_buun02", + "anime_jien02", + "anime_monar02", + "anime_sasuga01", + "anime_youkanman02", + "file2_01", + "gikoneko_1", + "imanouchi_1", + "kossorisan", + "nigete", + "u_ame", + "5ta", + "anime_charhan01", + "anime_jien03", + "anime_monar03", + "anime_sasuga03", + "anime_youkanman03", + "fujisan", + "gikoneko2", + "iyahoo", + "kotatu", + "nono_ie", + "u_hoshi" +]; +export const quotes = [ + "Eres una buena persona.", + "Y por invertir en felaciones.", + "Fue un mensaje cachilupi.", + "holiwi :3", + "Hemos enviado a tu casa un ejército de prostitutas.", + "Fue un mensaje de PURA CALIDAD.", + "Ganaste frot gratis por una semana.", + "Te besaría en la boca.", + "Te invitaría a un café.", + "ミト━━━━━━⊂( ゚ ヮ゚)⊃━━━━━━ン!!!!!", + "Suenas como un bot muy desarrollado.", + "¿Usaste TheSaurus para escribir tu post?", + "(´・ω・`)", + "Plataformas del futuro para la web 1.0.", + "Gracias por utilizar Internet.", + "Plataformas del pasado para la web 2.0.", + "Elegiste bien. Elegiste calidad.", + "Espero que no hayas abusado del sage.", + "gRAciAs pOR Tu PAgA ;)", + "Gracias por tu papiro." +]; diff --git a/src/ReplyForm.js b/src/ReplyForm.js index 1aa71e5..33a6af4 100644 --- a/src/ReplyForm.js +++ b/src/ReplyForm.js @@ -3,91 +3,118 @@ import { Form, Segment, Button, Message } from "semantic-ui-react"; import { quotes } from "./Quotes"; class ReplyForm extends Component { - constructor(props) { - super(props); - this.state = { - name: "", - email: "", - message: "", - submittedName: "", - submittedEmail: "", - submittedMessage: "", - replyRes: null - } - this.handleChange = this.handleChange.bind(this); - this.handleSubmit = this.handleSubmit.bind(this); - } - - handleChange(e) { - const { name, value } = e.target; - this.setState({ [name]: value }) - } + constructor(props) { + super(props); + this.state = { + name: "", + email: "", + message: "", + submittedName: "", + submittedEmail: "", + submittedMessage: "", + replyRes: null + }; + this.handleChange = this.handleChange.bind(this); + this.handleSubmit = this.handleSubmit.bind(this); + } - handleSubmit() { - const { submittedName, submittedEmail, name, email, message } = this.state - this.setState({ submittedName: name, submittedEmail: email, submittedMessage: message }) - const data = { - board: this.props.dir, - parent: this.props.parent, - name: "", - email: "", - fielda: submittedName, - fieldb: submittedEmail, - message: message, - password: "bai-client" - } + handleChange(e) { + const { name, value } = e.target; + this.setState({ [name]: value }); + } - const formData = new FormData(); - for (var key in data) { - formData.append(key, data[key]); - } + handleSubmit() { + const { submittedName, submittedEmail, name, email, message } = this.state; + this.setState({ + submittedName: name, + submittedEmail: email, + submittedMessage: message + }); + const data = { + board: this.props.dir, + parent: this.props.parent, + name: "", + email: "", + fielda: submittedName, + fieldb: submittedEmail, + message: message, + password: "bai-client" + }; - fetch("https://bienvenidoainternet.org/cgi/api/post", { - method: "POST", - mode: "cors", - redirect: "follow", - body: formData - } - ).then((response) => { - return response.json() - }).then((resource) => { - console.log(resource); - this.setState({ replyRes: resource }); - } - ); + const formData = new FormData(); + for (var key in data) { + formData.append(key, data[key]); } - render() { - const { name, email, message, replyRes } = this.state; - return ( - - { - replyRes !== null ? - replyRes.state === "success" ? - ( - Gracias por tu post - {quotes[Math.floor(Math.random() * quotes.length)]}
- Nos tomó {replyRes.time_taken} segundos procesar tu mensaje. -
) : - ( - - {replyRes.state} - {replyRes.message} - - ) : null - } -
- - - - - - - -
- ); - } + fetch("https://bienvenidoainternet.org/cgi/api/post", { + method: "POST", + mode: "cors", + redirect: "follow", + body: formData + }) + .then(response => { + return response.json(); + }) + .then(resource => { + console.log(resource); + this.setState({ replyRes: resource }); + }); + } + render() { + const { name, email, message, replyRes } = this.state; + return ( + + {replyRes !== null ? ( + replyRes.state === "success" ? ( + + Gracias por tu post + {quotes[Math.floor(Math.random() * quotes.length)]} +
+ + Nos tomó {replyRes.time_taken} segundos procesar tu mensaje. + +
+ ) : ( + + {replyRes.state} + {replyRes.message} + + ) + ) : null} +
+ + + + + + + +
+ ); + } } -export default ReplyForm; \ No newline at end of file +export default ReplyForm; diff --git a/src/Thread.js b/src/Thread.js index 085a754..4d0f56d 100644 --- a/src/Thread.js +++ b/src/Thread.js @@ -1,92 +1,119 @@ import React, { Component } from "react"; -import { Header, Icon, Loader, Message, Segment, Comment } from "semantic-ui-react"; +import { + Header, + Icon, + Loader, + Message, + Segment, + Comment +} from "semantic-ui-react"; import Moment from "react-moment"; import "moment/locale/es"; import Post from "./Post"; import ReplyForm from "./ReplyForm"; class Thread extends Component { - constructor(props) { - super(props); - this.state = { - isLoading: true, - thread: [], - error: null - } - } - - componentDidMount() { + constructor(props) { + super(props); + this.state = { + isLoading: true, + thread: [], + error: null + }; + } - let apiURl; - if (this.props.id > 1000000) { - apiURl = `https://bienvenidoainternet.org/cgi/api/thread?dir=${this.props.dir}&ts=${this.props.id}`; - } else { - apiURl = `https://bienvenidoainternet.org/cgi/api/thread?dir=${this.props.dir}&id=${this.props.id}`; - } - console.log(apiURl); - fetch(apiURl) - .then((response) => { return response.json() }) - .then((resource => { - if (resource["state"] === "error") { - console.log("API Error:" + resource["message"]); - this.setState({ error: resource }); - } - this.setState({ isLoading: false, thread: resource }); - })) - .catch(console.error); + componentDidMount() { + let apiURl; + if (this.props.id > 1000000) { + apiURl = `https://bienvenidoainternet.org/cgi/api/thread?dir=${this.props.dir}&ts=${this.props.id}`; + } else { + apiURl = `https://bienvenidoainternet.org/cgi/api/thread?dir=${this.props.dir}&id=${this.props.id}`; } - render() { - const { isLoading, error } = this.state; - - if (isLoading) { - return ( - - Cargando ... - - ) + console.log(apiURl); + fetch(apiURl) + .then(response => { + return response.json(); + }) + .then(resource => { + if (resource["state"] === "error") { + console.log("API Error:" + resource["message"]); + this.setState({ error: resource }); } + this.setState({ isLoading: false, thread: resource }); + }) + .catch(console.error); + } + render() { + const { isLoading, error } = this.state; - if (error != null) { - return ( -
- - API Status: {error.state} -

{error.message}

-
-
- ); - } - - const { posts, subject, timestamp, total_replies, locked, id } = this.state.thread; - document.title = subject; + if (isLoading) { + return ( + + Cargando ... + + ); + } - return ( -
-
- - {subject}{locked ? : null} - + if (error != null) { + return ( +
+ + API Status: {error.state} +

{error.message}

+
+
+ ); + } - + const { + posts, + subject, + timestamp, + total_replies, + locked, + id + } = this.state.thread; + document.title = subject; - Creado
- {total_replies} respuestas
+ return ( +
+
+ + {subject} + {locked ? : null} + - -
+ + Creado +
+ {total_replies} respuestas +
+
+
- - {posts.map((post, index) => - - ) - } - + + {posts.map((post, index) => ( + + ))} + - + - API Link -
); - } + + API Link + +
+ ); + } } -export default Thread; \ No newline at end of file +export default Thread; diff --git a/src/index.html b/src/index.html index 027309e..5207dc3 100644 --- a/src/index.html +++ b/src/index.html @@ -1,16 +1,14 @@ - - - - - + + + + Bievenido a Internet - + - +
Doesn't work :(
- - - \ No newline at end of file + + -- cgit v1.2.1-18-gbd029