├── .gitignore ├── LICENSE ├── README.md ├── craco.config.js ├── package.json ├── public ├── favicon.ico ├── index.html ├── manifest.json └── robots.txt ├── src ├── App.css ├── App.js ├── App.test.js ├── assets │ ├── demo.gif │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── favicon.ico │ ├── icon.png │ └── logo.png ├── components │ ├── Button │ │ └── Button.jsx │ ├── LanguageSelect │ │ └── LanguageSelect.jsx │ ├── LoadingArticle │ │ └── LoadingArticle.jsx │ ├── LoadingResult │ │ └── LoadingResult.jsx │ ├── Logo │ │ └── Logo.jsx │ ├── ReadMore │ │ └── ReadMore.jsx │ ├── Result │ │ └── Result.jsx │ ├── ResultsList │ │ └── ResultsList.jsx │ ├── SearchBar │ │ └── SearchBar.jsx │ └── SearchHeader │ │ └── SearchHeader.jsx ├── contexts │ └── AppContext │ │ └── AppContext.jsx ├── fonts │ ├── Montserrat │ │ ├── Montserrat-Bold.ttf │ │ ├── Montserrat-Light.ttf │ │ ├── Montserrat-Medium.ttf │ │ ├── Montserrat-Regular.ttf │ │ └── OFL.txt │ ├── Roboto │ │ ├── LICENSE.txt │ │ ├── Roboto-Bold.ttf │ │ ├── Roboto-Light.ttf │ │ ├── Roboto-Medium.ttf │ │ └── Roboto-Regular.ttf │ └── Vollkorn │ │ ├── OFL.txt │ │ └── Vollkorn-Medium.ttf ├── index.css ├── index.js ├── pages │ ├── Home.jsx │ ├── Results.jsx │ └── Site.jsx ├── reportWebVitals.js ├── setupTests.js └── utils │ ├── formatResults.js │ └── templates.js ├── tailwind.config.js └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Kenny Cruz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | ![](./src/assets/logo.png) 4 | 5 | ![](https://img.shields.io/github/license/jokenox/Goopt?color=blue) ![](https://img.shields.io/badge/PRs-welcome-orange) 6 | 7 | **Search Engine** for a **Procedural Simulation** of the **Web** with **GPT-3** 8 | 9 |
10 | 11 | --- 12 | 13 | > **Web 4.0** could be the propitious evolution for the **procedural web**. 14 | 15 | Goopt is an experiment in what the "**procedural web**" could be. This new web will use **procedural content generation** to create varied content, **completely synthetic**, since these are **generated by algorithms** and **artificial intelligence**. For now, the content is only text that is being generated automatically with **GPT-3**, the recent OpenAI model. 16 | 17 | Goopt works as if it were a search engine, allowing us to search for any term, obtain related results and access their content. Simulating in this way the experience of browsing the web. 18 | 19 | ![Goopt Demo](./src/assets/demo.gif) 20 | 21 | ## Procedural Web 22 | 23 | The procedural web will be the future of the web. It will offer us infinite content, since it will not be necessary that someone has written or created it before. All the content will be synthetic and generated at the moment, with infinite possibilities. From informative text, articles, images, videos, to games, applications and services with interfaces and functionality that are automatically generated. All this adapted to our queries and needs, and increasingly personalized to our preferences. 24 | 25 | Web 4.0 could be the propitious evolution for the procedural web. The automation that this new version of the web poses about applications, services, interfaces, APIs, devices and others, could be exploited by connecting them with the procedural web. These reality data interfaces would help empower and enhance their generative capabilities, as well as connect their functionality to the real world, having services and devices on which to execute actions. This makes the procedural web even more interesting, because it endows it with cybernetic capabilities. 26 | 27 | The procedural web is based on natural language processing (NLP) and procedural content generation (PCG). Advances in these fields, as well as in the field of computational creativity, will allow us to generate increasingly better synthetic multimedia, thus nurturing the procedural web with more and better content. It will be interesting to see if this content comes to satisfy us more than the traditional web and human creation. Maybe one day we won't ever be able to distinguish. 28 | 29 | ## Usage 30 | 31 | Being an experimental project there is no public access online version, you have to replicate the project yourself as a developer and use your own [OpenAI API Key](https://openai.com/api/). 32 | 33 | ### Install 34 | 35 | Clone the project: 36 | 37 | ```bash 38 | $ git clone https://github.com/jokenox/Goopt.git 39 | $ cd Goopt 40 | ``` 41 | 42 | Make a file called ```.env.local``` in the root of the project and write a line with your OpenAI API Key to it: 43 | 44 | ``` 45 | REACT_APP_OPENAI_API_KEY=YOUR_API_KEY_HERE 46 | ``` 47 | 48 | And finally install the project and its dependencies and start it: 49 | 50 | ```bash 51 | $ yarn install 52 | $ yarn start # visit http://localhost:3000 53 | ``` 54 | 55 | ## License 56 | Licensed under the [MIT License](./LICENSE).
57 | Copyright (c) 2022 [Kenny Cruz](https://github.com/jokenox). 58 | -------------------------------------------------------------------------------- /craco.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | style: { 3 | postcss: { 4 | plugins: [ 5 | require('tailwindcss'), 6 | require('autoprefixer'), 7 | ], 8 | }, 9 | }, 10 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "goopt", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@craco/craco": "^6.4.3", 7 | "autoprefixer": "^9", 8 | "cra-template": "1.1.2", 9 | "openai-api": "^1.2.6", 10 | "postcss": "^7", 11 | "react": "^17.0.2", 12 | "react-dom": "^17.0.2", 13 | "react-router-dom": "^6.1.1", 14 | "react-scripts": "4.0.3", 15 | "web-vitals": "^2.1.2" 16 | }, 17 | "scripts": { 18 | "start": "craco start", 19 | "build": "craco build", 20 | "test": "craco test", 21 | "eject": "react-scripts eject" 22 | }, 23 | "eslintConfig": { 24 | "extends": [ 25 | "react-app", 26 | "react-app/jest" 27 | ] 28 | }, 29 | "browserslist": { 30 | "production": [ 31 | ">0.2%", 32 | "not dead", 33 | "not op_mini all" 34 | ], 35 | "development": [ 36 | "last 1 chrome version", 37 | "last 1 firefox version", 38 | "last 1 safari version" 39 | ] 40 | }, 41 | "devDependencies": { 42 | "tailwindcss": "npm:@tailwindcss/postcss7-compat" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jokenox/Goopt/58f025280bfdf1f4458c94539b29c73b976933cf/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | Goopt 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import './App.css'; 2 | 3 | import { 4 | BrowserRouter, 5 | Routes, 6 | Route 7 | } from "react-router-dom"; 8 | 9 | import { AppContextProvider } from './contexts/AppContext/AppContext'; 10 | 11 | import Home from './pages/Home'; 12 | import Results from './pages/Results'; 13 | import Site from './pages/Site'; 14 | 15 | function App() { 16 | return ( 17 |
18 | 19 | 20 | 21 | } /> 22 | } /> 23 | } /> 24 | 25 | 26 | 27 |
28 | ); 29 | } 30 | 31 | export default App; 32 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /src/assets/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jokenox/Goopt/58f025280bfdf1f4458c94539b29c73b976933cf/src/assets/demo.gif -------------------------------------------------------------------------------- /src/assets/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jokenox/Goopt/58f025280bfdf1f4458c94539b29c73b976933cf/src/assets/favicon-16x16.png -------------------------------------------------------------------------------- /src/assets/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jokenox/Goopt/58f025280bfdf1f4458c94539b29c73b976933cf/src/assets/favicon-32x32.png -------------------------------------------------------------------------------- /src/assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jokenox/Goopt/58f025280bfdf1f4458c94539b29c73b976933cf/src/assets/favicon.ico -------------------------------------------------------------------------------- /src/assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jokenox/Goopt/58f025280bfdf1f4458c94539b29c73b976933cf/src/assets/icon.png -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jokenox/Goopt/58f025280bfdf1f4458c94539b29c73b976933cf/src/assets/logo.png -------------------------------------------------------------------------------- /src/components/Button/Button.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | function Button({ children, onClick, className = '' }) { 4 | return ( 5 | 16 | ); 17 | } 18 | 19 | export default Button; 20 | -------------------------------------------------------------------------------- /src/components/LanguageSelect/LanguageSelect.jsx: -------------------------------------------------------------------------------- 1 | import React, { useContext } from 'react'; 2 | 3 | import { AppContext } from '../../contexts/AppContext/AppContext'; 4 | 5 | function LanguageSelect() { 6 | const { 7 | language, 8 | selectLanguage 9 | } = useContext(AppContext); 10 | 11 | const handleChange = (event) => { 12 | selectLanguage(event.target.value); 13 | }; 14 | 15 | return ( 16 |
17 | 18 | 19 | 28 |
29 | ); 30 | } 31 | 32 | export default LanguageSelect; -------------------------------------------------------------------------------- /src/components/LoadingArticle/LoadingArticle.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | function LoadingArticle() { 4 | return ( 5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | ); 21 | } 22 | 23 | export default LoadingArticle; 24 | -------------------------------------------------------------------------------- /src/components/LoadingResult/LoadingResult.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | function LoadingResult() { 4 | return ( 5 |
6 |
7 | 8 |
9 |
10 |
11 |
12 | 13 | 14 |
15 | 16 |
17 |
18 |
19 |
20 |
21 | ); 22 | } 23 | 24 | export default LoadingResult; 25 | -------------------------------------------------------------------------------- /src/components/Logo/Logo.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | function Logo({ className = '' }) { 4 | return ( 5 |
6 | G 7 | o 8 | o 9 | p 10 | t 11 |
12 | ); 13 | } 14 | 15 | export default Logo; 16 | 17 | -------------------------------------------------------------------------------- /src/components/ReadMore/ReadMore.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | function ReadMore({ onClick, className }) { 4 | return ( 5 | 14 | ); 15 | } 16 | 17 | export default ReadMore; 18 | -------------------------------------------------------------------------------- /src/components/Result/Result.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { Link } from "react-router-dom"; 3 | 4 | function Result({ title, text }) { 5 | let [titleColor, setTitleColor] = useState('text-goolink'); 6 | 7 | const handleClick = () => { 8 | setTitleColor('text-goolink-visited'); 9 | }; 10 | 11 | return ( 12 |
13 | 23 | { title } 24 | 25 | 26 |

27 | { text } 28 |

29 |
30 | ); 31 | } 32 | 33 | export default Result; 34 | -------------------------------------------------------------------------------- /src/components/ResultsList/ResultsList.jsx: -------------------------------------------------------------------------------- 1 | import React, { useContext } from 'react'; 2 | 3 | import { AppContext } from '../../contexts/AppContext/AppContext'; 4 | 5 | import Result from '../Result/Result'; 6 | import LoadingResult from '../LoadingResult/LoadingResult'; 7 | 8 | function ResultsList() { 9 | const { searchResults, isLoadingResults } = useContext(AppContext); 10 | 11 | const resultsList = searchResults.map((result, index) => { 12 | return ( 13 | 18 | ); 19 | }); 20 | 21 | return ( 22 |
23 | { resultsList.length > 0 && 24 | resultsList 25 | } 26 | 27 | { (!resultsList.length || isLoadingResults) && 28 | 29 | } 30 |
31 | ); 32 | } 33 | 34 | export default ResultsList; -------------------------------------------------------------------------------- /src/components/SearchBar/SearchBar.jsx: -------------------------------------------------------------------------------- 1 | import React, { useContext } from 'react'; 2 | 3 | import { AppContext } from '../../contexts/AppContext/AppContext'; 4 | 5 | function SearchBar({ className = '', autoFocus = false }) { 6 | const { 7 | searchTerm, 8 | setSearchTerm, 9 | gooptSearch 10 | } = useContext(AppContext); 11 | 12 | const handleChange = (e) => { 13 | setSearchTerm(e.target.value); 14 | } 15 | 16 | const handleKeyDown = (e) => { 17 | if (e.keyCode === 13) { 18 | gooptSearch(searchTerm); 19 | } 20 | }; 21 | 22 | const clearSearchBarText = () => { 23 | setSearchTerm(''); 24 | 25 | document.querySelector('input').focus(); 26 | }; 27 | 28 | return ( 29 |
34 |
35 | 39 | 40 | 41 |
42 | 43 | 51 | 52 | { searchTerm.length > 0 && 53 |
54 | 64 |
65 | } 66 |
67 | ); 68 | } 69 | 70 | export default SearchBar; 71 | -------------------------------------------------------------------------------- /src/components/SearchHeader/SearchHeader.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import Logo from '../Logo/Logo'; 4 | import SearchBar from '../SearchBar/SearchBar'; 5 | 6 | function SearchHeader() { 7 | return ( 8 |
9 | 10 | 11 | 12 | 13 |
14 | ); 15 | } 16 | 17 | export default SearchHeader; 18 | -------------------------------------------------------------------------------- /src/contexts/AppContext/AppContext.jsx: -------------------------------------------------------------------------------- 1 | import React, { createContext, useState, useRef } from 'react'; 2 | import { useNavigate } from "react-router-dom"; 3 | import OpenAI from 'openai-api'; 4 | 5 | import formatResults from '../../utils/formatResults'; 6 | import { SearchTemplate, ArticleTemplate } from '../../utils/templates'; 7 | 8 | const AppContext = createContext(); 9 | 10 | const AppContextProvider = ({ children }) => { 11 | const navigate = useNavigate(); 12 | const openai = new OpenAI(process.env.REACT_APP_OPENAI_API_KEY); 13 | 14 | const [language, setLanguage] = useState((localStorage.getItem('language') || 'en')); 15 | const [searchTerm, setSearchTerm] = useState(''); 16 | const [searchResults, setSearchResults] = useState([]); 17 | const [isLoadingResults, setIsLoadingResults] = useState(false); 18 | const [isLoadingArticle, setIsLoadingArticle] = useState(false); 19 | const lastResultsString = useRef(''); 20 | 21 | const selectLanguage = (lang) => { 22 | localStorage.setItem('language', lang); 23 | setLanguage(lang); 24 | }; 25 | 26 | const generateArticleText = async (text) => { 27 | let gptResponse; 28 | 29 | setIsLoadingArticle(true); 30 | 31 | try { 32 | gptResponse = await openai.complete({ 33 | engine: 'text-davinci-003', 34 | prompt: text.trim(), 35 | maxTokens: 500, 36 | temperature: 0.7, 37 | topP: 1, 38 | presencePenalty: 0, 39 | frequencyPenalty: 2, 40 | bestOf: 1, 41 | n: 1, 42 | stream: false 43 | }); 44 | 45 | console.log(gptResponse.data.choices[0].text); 46 | 47 | setIsLoadingArticle(false); 48 | 49 | return gptResponse.data.choices[0].text; 50 | } catch (error) { 51 | alert('There are problems accessing the API'); 52 | window.location.href = '/'; 53 | } 54 | }; 55 | 56 | const generateResults = async (searchTerm) => { 57 | const lastResults = lastResultsString.current; 58 | 59 | const query = getSearchTemplate() + searchTerm + '\n\n{' + lastResults; 60 | 61 | let gptResponse; 62 | 63 | setIsLoadingResults(true); 64 | 65 | try { 66 | gptResponse = await openai.complete({ 67 | engine: 'text-davinci-001', 68 | prompt: query, 69 | maxTokens: 1000, 70 | temperature: 1, 71 | topP: 1, 72 | presencePenalty: 0, 73 | frequencyPenalty: 2, 74 | bestOf: 1, 75 | n: 1, 76 | stream: false, 77 | stop: ['"""'] 78 | }); 79 | 80 | //console.log(gptResponse.data.choices[0].text); 81 | 82 | lastResultsString.current = gptResponse.data.choices[0].text; 83 | 84 | setIsLoadingResults(false); 85 | 86 | return gptResponse.data.choices[0].text; 87 | } catch (error) { 88 | alert('There are problems accessing the API'); 89 | window.location.href = '/'; 90 | } 91 | }; 92 | 93 | const getResults = async (term) => { 94 | setSearchResults([]); 95 | 96 | let results = formatResults(await generateResults(term)); 97 | let numberOfResults = results.length; 98 | 99 | setSearchResults(results); 100 | 101 | if (numberOfResults < 3) getMoreResults(numberOfResults); 102 | }; 103 | 104 | const getMoreResults = async (numberOfPrevResults) => { 105 | let newResults = formatResults(await generateResults(searchTerm)); 106 | let numberOfResults = numberOfPrevResults + newResults.length; 107 | 108 | setSearchResults(prev => [...prev, ...newResults]); 109 | 110 | if (numberOfResults < 3) getMoreResults(numberOfResults); 111 | }; 112 | 113 | const gooptSearch = (term) => { 114 | if (term.trim().length > 0) { 115 | navigate('/results?search=' + term.trim()); 116 | 117 | getResults(term.trim()); 118 | } 119 | }; 120 | 121 | const imFeelingLucky = async (term) => { 122 | if (searchTerm.trim().length > 0) { 123 | navigate('/site?term=' + term.trim()); 124 | 125 | await getResults(term.trim()); 126 | } 127 | }; 128 | 129 | const getSearchTemplate = (lang = language) => { 130 | switch (lang) { 131 | case 'en': 132 | return SearchTemplate.en; 133 | 134 | case 'es': 135 | return SearchTemplate.es; 136 | 137 | case 'eo': 138 | return SearchTemplate.eo; 139 | 140 | default: 141 | return false; 142 | }; 143 | }; 144 | 145 | const getArticleTemplate = (lang = language) => { 146 | switch (lang) { 147 | case 'en': 148 | return ArticleTemplate.en; 149 | 150 | case 'es': 151 | return ArticleTemplate.es; 152 | 153 | case 'eo': 154 | return ArticleTemplate.eo; 155 | 156 | default: 157 | return false; 158 | }; 159 | }; 160 | 161 | return ( 162 | 176 | { children } 177 | 178 | ); 179 | 180 | 181 | }; 182 | 183 | export { AppContext, AppContextProvider }; 184 | -------------------------------------------------------------------------------- /src/fonts/Montserrat/Montserrat-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jokenox/Goopt/58f025280bfdf1f4458c94539b29c73b976933cf/src/fonts/Montserrat/Montserrat-Bold.ttf -------------------------------------------------------------------------------- /src/fonts/Montserrat/Montserrat-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jokenox/Goopt/58f025280bfdf1f4458c94539b29c73b976933cf/src/fonts/Montserrat/Montserrat-Light.ttf -------------------------------------------------------------------------------- /src/fonts/Montserrat/Montserrat-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jokenox/Goopt/58f025280bfdf1f4458c94539b29c73b976933cf/src/fonts/Montserrat/Montserrat-Medium.ttf -------------------------------------------------------------------------------- /src/fonts/Montserrat/Montserrat-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jokenox/Goopt/58f025280bfdf1f4458c94539b29c73b976933cf/src/fonts/Montserrat/Montserrat-Regular.ttf -------------------------------------------------------------------------------- /src/fonts/Montserrat/OFL.txt: -------------------------------------------------------------------------------- 1 | Copyright 2011 The Montserrat Project Authors (https://github.com/JulietaUla/Montserrat) 2 | 3 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 | This license is copied below, and is also available with a FAQ at: 5 | http://scripts.sil.org/OFL 6 | 7 | 8 | ----------------------------------------------------------- 9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 | ----------------------------------------------------------- 11 | 12 | PREAMBLE 13 | The goals of the Open Font License (OFL) are to stimulate worldwide 14 | development of collaborative font projects, to support the font creation 15 | efforts of academic and linguistic communities, and to provide a free and 16 | open framework in which fonts may be shared and improved in partnership 17 | with others. 18 | 19 | The OFL allows the licensed fonts to be used, studied, modified and 20 | redistributed freely as long as they are not sold by themselves. The 21 | fonts, including any derivative works, can be bundled, embedded, 22 | redistributed and/or sold with any software provided that any reserved 23 | names are not used by derivative works. The fonts and derivatives, 24 | however, cannot be released under any other type of license. The 25 | requirement for fonts to remain under this license does not apply 26 | to any document created using the fonts or their derivatives. 27 | 28 | DEFINITIONS 29 | "Font Software" refers to the set of files released by the Copyright 30 | Holder(s) under this license and clearly marked as such. This may 31 | include source files, build scripts and documentation. 32 | 33 | "Reserved Font Name" refers to any names specified as such after the 34 | copyright statement(s). 35 | 36 | "Original Version" refers to the collection of Font Software components as 37 | distributed by the Copyright Holder(s). 38 | 39 | "Modified Version" refers to any derivative made by adding to, deleting, 40 | or substituting -- in part or in whole -- any of the components of the 41 | Original Version, by changing formats or by porting the Font Software to a 42 | new environment. 43 | 44 | "Author" refers to any designer, engineer, programmer, technical 45 | writer or other person who contributed to the Font Software. 46 | 47 | PERMISSION & CONDITIONS 48 | Permission is hereby granted, free of charge, to any person obtaining 49 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 50 | redistribute, and sell modified and unmodified copies of the Font 51 | Software, subject to the following conditions: 52 | 53 | 1) Neither the Font Software nor any of its individual components, 54 | in Original or Modified Versions, may be sold by itself. 55 | 56 | 2) Original or Modified Versions of the Font Software may be bundled, 57 | redistributed and/or sold with any software, provided that each copy 58 | contains the above copyright notice and this license. These can be 59 | included either as stand-alone text files, human-readable headers or 60 | in the appropriate machine-readable metadata fields within text or 61 | binary files as long as those fields can be easily viewed by the user. 62 | 63 | 3) No Modified Version of the Font Software may use the Reserved Font 64 | Name(s) unless explicit written permission is granted by the corresponding 65 | Copyright Holder. This restriction only applies to the primary font name as 66 | presented to the users. 67 | 68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 69 | Software shall not be used to promote, endorse or advertise any 70 | Modified Version, except to acknowledge the contribution(s) of the 71 | Copyright Holder(s) and the Author(s) or with their explicit written 72 | permission. 73 | 74 | 5) The Font Software, modified or unmodified, in part or in whole, 75 | must be distributed entirely under this license, and must not be 76 | distributed under any other license. The requirement for fonts to 77 | remain under this license does not apply to any document created 78 | using the Font Software. 79 | 80 | TERMINATION 81 | This license becomes null and void if any of the above conditions are 82 | not met. 83 | 84 | DISCLAIMER 85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 | OTHER DEALINGS IN THE FONT SOFTWARE. 94 | -------------------------------------------------------------------------------- /src/fonts/Roboto/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /src/fonts/Roboto/Roboto-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jokenox/Goopt/58f025280bfdf1f4458c94539b29c73b976933cf/src/fonts/Roboto/Roboto-Bold.ttf -------------------------------------------------------------------------------- /src/fonts/Roboto/Roboto-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jokenox/Goopt/58f025280bfdf1f4458c94539b29c73b976933cf/src/fonts/Roboto/Roboto-Light.ttf -------------------------------------------------------------------------------- /src/fonts/Roboto/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jokenox/Goopt/58f025280bfdf1f4458c94539b29c73b976933cf/src/fonts/Roboto/Roboto-Medium.ttf -------------------------------------------------------------------------------- /src/fonts/Roboto/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jokenox/Goopt/58f025280bfdf1f4458c94539b29c73b976933cf/src/fonts/Roboto/Roboto-Regular.ttf -------------------------------------------------------------------------------- /src/fonts/Vollkorn/OFL.txt: -------------------------------------------------------------------------------- 1 | Copyright 2017 The Vollkorn Project Authors (https://github.com/FAlthausen/Vollkorn-Typeface) 2 | 3 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 | This license is copied below, and is also available with a FAQ at: 5 | http://scripts.sil.org/OFL 6 | 7 | 8 | ----------------------------------------------------------- 9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 | ----------------------------------------------------------- 11 | 12 | PREAMBLE 13 | The goals of the Open Font License (OFL) are to stimulate worldwide 14 | development of collaborative font projects, to support the font creation 15 | efforts of academic and linguistic communities, and to provide a free and 16 | open framework in which fonts may be shared and improved in partnership 17 | with others. 18 | 19 | The OFL allows the licensed fonts to be used, studied, modified and 20 | redistributed freely as long as they are not sold by themselves. The 21 | fonts, including any derivative works, can be bundled, embedded, 22 | redistributed and/or sold with any software provided that any reserved 23 | names are not used by derivative works. The fonts and derivatives, 24 | however, cannot be released under any other type of license. The 25 | requirement for fonts to remain under this license does not apply 26 | to any document created using the fonts or their derivatives. 27 | 28 | DEFINITIONS 29 | "Font Software" refers to the set of files released by the Copyright 30 | Holder(s) under this license and clearly marked as such. This may 31 | include source files, build scripts and documentation. 32 | 33 | "Reserved Font Name" refers to any names specified as such after the 34 | copyright statement(s). 35 | 36 | "Original Version" refers to the collection of Font Software components as 37 | distributed by the Copyright Holder(s). 38 | 39 | "Modified Version" refers to any derivative made by adding to, deleting, 40 | or substituting -- in part or in whole -- any of the components of the 41 | Original Version, by changing formats or by porting the Font Software to a 42 | new environment. 43 | 44 | "Author" refers to any designer, engineer, programmer, technical 45 | writer or other person who contributed to the Font Software. 46 | 47 | PERMISSION & CONDITIONS 48 | Permission is hereby granted, free of charge, to any person obtaining 49 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 50 | redistribute, and sell modified and unmodified copies of the Font 51 | Software, subject to the following conditions: 52 | 53 | 1) Neither the Font Software nor any of its individual components, 54 | in Original or Modified Versions, may be sold by itself. 55 | 56 | 2) Original or Modified Versions of the Font Software may be bundled, 57 | redistributed and/or sold with any software, provided that each copy 58 | contains the above copyright notice and this license. These can be 59 | included either as stand-alone text files, human-readable headers or 60 | in the appropriate machine-readable metadata fields within text or 61 | binary files as long as those fields can be easily viewed by the user. 62 | 63 | 3) No Modified Version of the Font Software may use the Reserved Font 64 | Name(s) unless explicit written permission is granted by the corresponding 65 | Copyright Holder. This restriction only applies to the primary font name as 66 | presented to the users. 67 | 68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 69 | Software shall not be used to promote, endorse or advertise any 70 | Modified Version, except to acknowledge the contribution(s) of the 71 | Copyright Holder(s) and the Author(s) or with their explicit written 72 | permission. 73 | 74 | 5) The Font Software, modified or unmodified, in part or in whole, 75 | must be distributed entirely under this license, and must not be 76 | distributed under any other license. The requirement for fonts to 77 | remain under this license does not apply to any document created 78 | using the Font Software. 79 | 80 | TERMINATION 81 | This license becomes null and void if any of the above conditions are 82 | not met. 83 | 84 | DISCLAIMER 85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 | OTHER DEALINGS IN THE FONT SOFTWARE. 94 | -------------------------------------------------------------------------------- /src/fonts/Vollkorn/Vollkorn-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jokenox/Goopt/58f025280bfdf1f4458c94539b29c73b976933cf/src/fonts/Vollkorn/Vollkorn-Medium.ttf -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | @font-face { 6 | font-family: 'Roboto'; 7 | src: local('Roboto'), url(./fonts/Roboto/Roboto-Regular.ttf) format('truetype'); 8 | } 9 | 10 | @font-face { 11 | font-family: 'Vollkorn'; 12 | src: local('Vollkorn'), url(./fonts/Vollkorn/Vollkorn-Medium.ttf) format('truetype'); 13 | } 14 | 15 | @font-face { 16 | font-family: 'Montserrat'; 17 | src: local('Montserrat'), url(./fonts/Montserrat/Montserrat-Bold.ttf) format('truetype'); 18 | } 19 | 20 | .font-roboto { 21 | font-family: 'Roboto', sans-serif; 22 | } 23 | 24 | .font-vollkorn { 25 | font-family: 'Vollkorn', serif; 26 | } 27 | 28 | .font-montserrat { 29 | font-family: 'Montserrat', sans-serif; 30 | } -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /src/pages/Home.jsx: -------------------------------------------------------------------------------- 1 | import React, { useContext } from 'react'; 2 | 3 | import { AppContext } from '../contexts/AppContext/AppContext'; 4 | 5 | import Logo from '../components/Logo/Logo'; 6 | import SearchBar from '../components/SearchBar/SearchBar'; 7 | import Button from '../components/Button/Button'; 8 | import LanguageSelect from '../components/LanguageSelect/LanguageSelect'; 9 | 10 | function Home() { 11 | const { 12 | searchTerm, 13 | gooptSearch, 14 | imFeelingLucky, 15 | } = useContext(AppContext); 16 | 17 | return ( 18 |
19 |
20 | 21 | 22 | 26 | 27 |
28 | 34 | 35 | 41 |
42 |
43 | 44 |
45 | Don't be human. 46 | 47 | 48 |
49 |
50 | ); 51 | } 52 | 53 | export default Home; 54 | -------------------------------------------------------------------------------- /src/pages/Results.jsx: -------------------------------------------------------------------------------- 1 | import React, { useContext } from 'react'; 2 | 3 | import { AppContext } from '../contexts/AppContext/AppContext'; 4 | 5 | import SearchHeader from '../components/SearchHeader/SearchHeader'; 6 | import ResultsList from '../components/ResultsList/ResultsList'; 7 | import Button from '../components/Button/Button'; 8 | 9 | function Results() { 10 | const { isLoadingResults, getMoreResults } = useContext(AppContext); 11 | 12 | return ( 13 |
14 | 15 | 16 |
17 |
18 | About ∞ results 19 |
20 | 21 | 22 | 23 | { !isLoadingResults && 24 | 30 | } 31 |
32 |
33 | ); 34 | } 35 | 36 | export default Results; 37 | -------------------------------------------------------------------------------- /src/pages/Site.jsx: -------------------------------------------------------------------------------- 1 | import React, { useContext, useEffect, useState } from 'react'; 2 | 3 | import { AppContext } from '../contexts/AppContext/AppContext'; 4 | 5 | import LoadingArticle from '../components/LoadingArticle/LoadingArticle'; 6 | import ReadMore from '../components/ReadMore/ReadMore'; 7 | 8 | function Site() { 9 | const { 10 | searchResults, 11 | generateArticleText, 12 | isLoadingArticle, 13 | getArticleTemplate 14 | } = useContext(AppContext); 15 | 16 | const queryParams = new URLSearchParams(window.location.search); 17 | 18 | let [title, setTitle] = useState(queryParams.get('title')); 19 | let initialText = queryParams.get('text'); 20 | 21 | let [text, setText] = useState(getArticleTemplate() + initialText); 22 | 23 | useEffect(() => { 24 | initArticle(); 25 | }); 26 | 27 | const initArticle = () => { 28 | if (searchResults[0] && !title) { 29 | setTitle(searchResults[0].title); 30 | setText(getArticleTemplate() + searchResults[0].text); 31 | } 32 | 33 | if (title && text.length < 800) { 34 | loadArticle(); 35 | } 36 | }; 37 | 38 | const loadArticle = async () => { 39 | let articleText = text.replace(/\s*...$/, ''); 40 | 41 | let articleNewText = await generateArticleText(articleText); 42 | 43 | setText(articleText + articleNewText); 44 | }; 45 | 46 | const formatArticleText = (text) => { 47 | let paragraphs = text.slice(text.indexOf('"""') + 4).split('\n'); 48 | 49 | let formattedText = paragraphs.map((paragraph, index) => { 50 | return ( 51 |

52 | { paragraph } 53 |

54 | ) 55 | }); 56 | 57 | return ( 58 |
59 | { formattedText } 60 |
61 | ); 62 | }; 63 | 64 | 65 | return ( 66 |
67 |
68 |

69 | { title } 70 |

71 | 72 |

73 | { text !== getArticleTemplate() + initialText && 74 | formatArticleText(text) 75 | } 76 | 77 | { (isLoadingArticle || !title) && 78 | 79 | } 80 |

81 | 82 | { (!isLoadingArticle && title) && 83 | 84 | } 85 |
86 |
87 | ); 88 | } 89 | 90 | export default Site; 91 | -------------------------------------------------------------------------------- /src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /src/utils/formatResults.js: -------------------------------------------------------------------------------- 1 | const filterValidResults = (results) => { 2 | return results.filter(result => { 3 | return result.title && result.text; 4 | }); 5 | }; 6 | 7 | const removeNewlinesAndSpaces = (resultString) => { 8 | return resultString.trim().replace(/(\n+|\s+)/g, ' '); 9 | }; 10 | 11 | // Function to fix common errors in the JSON structure of a generated result. 12 | const fixJsonStructure = (jsonString) => { 13 | let json = jsonString.trim(); 14 | 15 | json = json.replace(/^.*{/, '{') 16 | .replace(/}\s*.*$/, '}'); 17 | 18 | let start = json[0]; 19 | let end = json[json.length - 1]; 20 | 21 | if (start !== '{') json = `{${json}`; 22 | 23 | if (end !== '}') { 24 | if (end === ',') json = json.slice(0, -1); 25 | 26 | if (end !== '"') json = `${json}"`; 27 | 28 | json = `${json}}`; 29 | } 30 | 31 | json = json.replace(/{\s*("|')\s*/g, '{"') 32 | .replace(/\s*("|')\s*}/g, '"}') 33 | .replace(/\s*("|')\s*:\s*("|')\s*/g, '":"') 34 | .replace(/\s*("|')\s*,\s*("|')\s*/g, '","'); 35 | 36 | return json; 37 | }; 38 | 39 | // Function to fix the end of the "text" property of a result, 40 | // so that it ends with ellipsis. 41 | const fixEndOfText = (resultJson) => { 42 | let result = resultJson; 43 | 44 | if (result) result.text = result.text.replace(/\s*\.*$/, ' ...'); 45 | else result = {}; 46 | 47 | return result; 48 | }; 49 | 50 | // Function to format the results, fix the JSON structure, 51 | // parse the JSON, and filter the valid results. 52 | const formatResults = (resultsString) => { 53 | let results = resultsString.trim().split(/}\s*{/); 54 | 55 | results = results.map((resultString) => { 56 | let resultJson = {}; 57 | 58 | let result = removeNewlinesAndSpaces(resultString); 59 | result = fixJsonStructure(result); 60 | 61 | try { 62 | resultJson = JSON.parse(result); 63 | resultJson = fixEndOfText(resultJson); 64 | } catch (e) {} 65 | 66 | return resultJson; 67 | }); 68 | 69 | return filterValidResults(results); 70 | }; 71 | 72 | export default formatResults; -------------------------------------------------------------------------------- /src/utils/templates.js: -------------------------------------------------------------------------------- 1 | const SearchTemplate = { 2 | en: "Respond in JSON as if it were the result of a Google search.\nThe results should be informative, relevant, interesting, with 150 to 400 letters.\n\"\"\"\nSearch: Chess\n\n{\"title\": \"What is Chess?\",\"text\": \"Chess is a board game for two opponents in which each player has 16 movable pieces that are placed on a board, divided into 64 squares or squares. In its competitive version, it is considered as a sport, although nowadays it clearly has a social, educational and therapeutic dimension ...\"}\n\n{\"title\": \"How to play Chess (rules)\",\"text\": \"The rules of chess are not as complicated as they seem. More and more educational centers are paying special attention to chess for children. A game that improves creativity, enhances memory, increases reading speed and helps to solve problems, among other benefits ...\"}\n\"\"\"\nSearch: ", 3 | es: "Responde en JSON como si fuera resultado de una búsqueda en Google.\nLos resultados deben ser informativos, relevantes, interesantes, con 150 a 400 letras.\n\"\"\"\nBuscar: Ajedrez\n\n{\"title\": \"¿Qué es el Ajedrez?\",\"text\": \"El ajedrez es un juego de tablero entre dos contrincantes en el que cada uno dispone al inicio de 16 piezas móviles que se colocan sobre un tablero,​ dividido en 64 casillas o escaques. En su versión de competición, está considerado como un deporte aunque en la actualidad tiene claramente una dimensión social,​ educativa​ y terapéutica ...\"}\n\n{\"title\": \"Cómo jugar al ajedrez (reglas del ajedrez)\",\"text\": \"Las reglas del ajedrez no son tan complicadas como parece. Cada vez son más los centros educativos que prestan especial atención al ajedrez para niños. Un juego que mejora la creatividad, potencia la memoria, incrementa la velocidad lectora y ayuda a resolver problemas, entre otros beneficios ...\"}\n\"\"\"\nBuscar: ", 4 | eo: "Respondu per JSON kvazaŭ ĝi estus la rezulto de serĉo en Google.\nLa rezultoj estu informaj, trafaj, interesaj, kun 150 ĝis 400 literoj.\n\"\"\"\nSerĉu: Ŝako\n\n{\"title\": \"Kio estas Ŝako?\",\"text\": \"Ŝako estas tabulludo inter du kontraŭuloj, en kiu ĉiu havas komence 16 movantajn pecojn, kiuj estas metitaj sur tabulon, dividitaj en 64 kvadratojn aŭ kvadratojn. En sia konkurenciva versio, ĝi estas konsiderata sporto kvankam nuntempe ĝi klare havas socian, edukan kaj terapian dimension ...\"}\n\n{\"title\": \"Kiel ludi ŝakon (reguloj)\",\"text\": \"La reguloj de ŝako ne estas tiel komplikaj kiel ŝajnas. Pli kaj pli multaj edukaj centroj atentas ŝakon por infanoj. Ludo, kiu plibonigas la kreemon, plibonigas memoron, pliigas legan rapidon kaj helpas solvi problemojn, inter aliaj avantaĝoj ...\"}\n\"\"\"\nSerĉi: " 5 | }; 6 | 7 | const ArticleTemplate = { 8 | en: "Write an article that is informative and interesting.\n\"\"\"\n", 9 | es: "Escribe un artículo que sea informativo e interesante.\n\"\"\"\n", 10 | eo: "Skribu artikolon kiu estas informa kaj interesa.\n\"\"\"\n" 11 | }; 12 | 13 | export { SearchTemplate, ArticleTemplate }; -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | content: [ 3 | "./src/**/*.{js,jsx}", 4 | ], 5 | theme: { 6 | extend: { 7 | colors: { 8 | goonavy: "#153648", 9 | gooblue: "#259BAB", 10 | goocyan: "#09B49A", 11 | gooviolet: "#696CC0", 12 | googray: { 13 | text: "#4d5156", 14 | DEFAULT: "#9AA0A6", 15 | light: "#DFE1E5", 16 | ultralight: "#F8F9FA", 17 | button: "#EFEFEF" 18 | }, 19 | goolink: { 20 | DEFAULT: "#1A0DAB", 21 | visited: "#609" 22 | } 23 | } 24 | } 25 | }, 26 | plugins: [], 27 | } 28 | --------------------------------------------------------------------------------