tiagoenriquez
commited on
Upload 49 files
Browse files- Dockerfile +27 -0
- README.md +4 -9
- app.py +35 -0
- models/.gitignore +1 -0
- models/Interpretador.py +21 -0
- models/__init__.py +0 -0
- models/__pycache__/Interpretador.cpython-310.pyc +0 -0
- models/__pycache__/__init__.cpython-310.pyc +0 -0
- pyvenv.cfg +3 -0
- requestsBaseModels/.gitignore +1 -0
- requestsBaseModels/InterpretadorRequestBaseModel.py +6 -0
- requestsBaseModels/__init__.py +0 -0
- requestsBaseModels/__pycache__/InterpretadorRequestBaseModel.cpython-310.pyc +0 -0
- requestsBaseModels/__pycache__/__init__.cpython-310.pyc +0 -0
- requirements.txt +75 -0
- responsesBaseModels/.gitignore +1 -0
- responsesBaseModels/InterpretadorResponseBaseModel.py +5 -0
- responsesBaseModels/__init__.py +0 -0
- responsesBaseModels/__pycache__/InterpretadorResponseBaseModel.cpython-310.pyc +0 -0
- responsesBaseModels/__pycache__/__init__.cpython-310.pyc +0 -0
- static/controllers/InterpretadorController.js +65 -0
- static/main.js +2 -0
- static/models/Interpretador.js +40 -0
- static/models/InterpretadorRequest.js +21 -0
- static/models/InterpretadorResponse.js +6 -0
- static/models/Questao.js +39 -0
- static/services/InterpretadorService.js +23 -0
- static/style.css +123 -0
- static/utils/Api.js +1 -0
- static/utils/Options.js +32 -0
- static/views/components/Button.js +11 -0
- static/views/components/ErroComponent.js +11 -0
- static/views/components/EsperaComponent.js +9 -0
- static/views/components/Heading.js +10 -0
- static/views/components/Label.js +12 -0
- static/views/components/Paragraph.js +10 -0
- static/views/components/TextArea.js +14 -0
- static/views/containers/Buttons.js +15 -0
- static/views/containers/PerguntasContainer.js +16 -0
- static/views/containers/QuestaoContainer.js +16 -0
- static/views/containers/QuestoesContainer.js +15 -0
- static/views/containers/TextoContainer.js +17 -0
- static/views/pages/CadastroDeTextoPage.js +18 -0
- static/views/pages/ErroPage.js +39 -0
- static/views/pages/Page.js +8 -0
- static/views/pages/PerguntaPage.js +48 -0
- static/views/pages/QuestoesPage.js +45 -0
- static/views/pages/TextoPage.js +34 -0
- templates/index.html +38 -0
Dockerfile
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use the official Python 3.10.12 image
|
2 |
+
FROM python:3.10.12
|
3 |
+
|
4 |
+
# Set the working directory to /code
|
5 |
+
WORKDIR /code
|
6 |
+
|
7 |
+
# Copy the current directory contents into the container at /code
|
8 |
+
COPY ./requirements.txt /code/requirements.txt
|
9 |
+
|
10 |
+
# Install requirements.txt
|
11 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
12 |
+
|
13 |
+
# Set up a new user named "user" with user ID 1000
|
14 |
+
RUN useradd -m -u 1000 user
|
15 |
+
# Switch to the "user" user
|
16 |
+
USER user
|
17 |
+
# Set home to the user's home directory
|
18 |
+
ENV HOME=/home/user \
|
19 |
+
PATH=/home/user/.local/bin:$PATH
|
20 |
+
|
21 |
+
# Set the working directory to the user's home directory
|
22 |
+
WORKDIR $HOME/app
|
23 |
+
|
24 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
25 |
+
COPY --chown=user . $HOME/app
|
26 |
+
|
27 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
CHANGED
@@ -1,11 +1,6 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
colorTo: gray
|
6 |
sdk: docker
|
7 |
pinned: false
|
8 |
-
license: mit
|
9 |
-
---
|
10 |
-
|
11 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
title: Interpretador de Texto
|
2 |
+
emoji: 🐢
|
3 |
+
colorFrom: purple
|
4 |
+
colorTo: blue
|
|
|
5 |
sdk: docker
|
6 |
pinned: false
|
|
|
|
|
|
|
|
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from fastapi.requests import Request
|
3 |
+
from fastapi.responses import HTMLResponse
|
4 |
+
from fastapi.staticfiles import StaticFiles
|
5 |
+
from fastapi.templating import Jinja2Templates
|
6 |
+
from models.Interpretador import Interpretador
|
7 |
+
from requestsBaseModels.InterpretadorRequestBaseModel import InterpretadorRequestBaseModel
|
8 |
+
from responsesBaseModels.InterpretadorResponseBaseModel import InterpretadorResponseBaseModel
|
9 |
+
|
10 |
+
|
11 |
+
app = FastAPI()
|
12 |
+
app.mount("/static", StaticFiles(directory="static"), name="static")
|
13 |
+
templates = Jinja2Templates(directory="templates")
|
14 |
+
|
15 |
+
|
16 |
+
@app.get('/', response_class=HTMLResponse)
|
17 |
+
async def main(request: Request):
|
18 |
+
context = {"request": request}
|
19 |
+
response = templates.TemplateResponse("index.html", context)
|
20 |
+
return response
|
21 |
+
|
22 |
+
|
23 |
+
@app.post('/', response_model=InterpretadorResponseBaseModel)
|
24 |
+
async def responder(request: InterpretadorRequestBaseModel):
|
25 |
+
texto = request.texto
|
26 |
+
pergunta = request.pergunta
|
27 |
+
interpretador = Interpretador(texto, pergunta)
|
28 |
+
resposta = interpretador.resposta
|
29 |
+
response = InterpretadorResponseBaseModel(resposta=resposta)
|
30 |
+
return response
|
31 |
+
|
32 |
+
|
33 |
+
if __name__ == "__main__":
|
34 |
+
import uvicorn
|
35 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
models/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
__pycache__
|
models/Interpretador.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
from transformers.pipelines.base import Pipeline
|
3 |
+
|
4 |
+
|
5 |
+
class Interpretador:
|
6 |
+
|
7 |
+
def __init__(self, texto: str, pergunta: str) -> None:
|
8 |
+
self._texto = texto
|
9 |
+
self._pergunta = pergunta
|
10 |
+
self._responder()
|
11 |
+
|
12 |
+
|
13 |
+
@property
|
14 |
+
def resposta(self) -> str:
|
15 |
+
return self._resposta
|
16 |
+
|
17 |
+
|
18 |
+
def _responder(self):
|
19 |
+
resposta_pipeline = pipeline("question-answering")
|
20 |
+
resposta_pipeline: Pipeline = resposta_pipeline(context = self._texto, question = self._pergunta)
|
21 |
+
self._resposta = str(resposta_pipeline["answer"])
|
models/__init__.py
ADDED
File without changes
|
models/__pycache__/Interpretador.cpython-310.pyc
ADDED
Binary file (1.08 kB). View file
|
|
models/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (164 Bytes). View file
|
|
pyvenv.cfg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
home = /usr/bin
|
2 |
+
include-system-site-packages = false
|
3 |
+
version = 3.10.12
|
requestsBaseModels/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
__pycache__
|
requestsBaseModels/InterpretadorRequestBaseModel.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pydantic import BaseModel
|
2 |
+
|
3 |
+
|
4 |
+
class InterpretadorRequestBaseModel(BaseModel):
|
5 |
+
texto: str
|
6 |
+
pergunta: str
|
requestsBaseModels/__init__.py
ADDED
File without changes
|
requestsBaseModels/__pycache__/InterpretadorRequestBaseModel.cpython-310.pyc
ADDED
Binary file (478 Bytes). View file
|
|
requestsBaseModels/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (176 Bytes). View file
|
|
requirements.txt
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
absl-py==2.1.0
|
2 |
+
annotated-types==0.7.0
|
3 |
+
anyio==4.4.0
|
4 |
+
astunparse==1.6.3
|
5 |
+
certifi==2024.6.2
|
6 |
+
charset-normalizer==3.3.2
|
7 |
+
click==8.1.7
|
8 |
+
dnspython==2.6.1
|
9 |
+
email_validator==2.2.0
|
10 |
+
exceptiongroup==1.2.1
|
11 |
+
fastapi==0.111.0
|
12 |
+
fastapi-cli==0.0.4
|
13 |
+
fastapi-sessions==0.3.2
|
14 |
+
filelock==3.15.4
|
15 |
+
flatbuffers==24.3.25
|
16 |
+
fsspec==2024.6.1
|
17 |
+
gast==0.6.0
|
18 |
+
google-pasta==0.2.0
|
19 |
+
grpcio==1.64.1
|
20 |
+
h11==0.14.0
|
21 |
+
h5py==3.11.0
|
22 |
+
httpcore==1.0.5
|
23 |
+
httptools==0.6.1
|
24 |
+
httpx==0.27.0
|
25 |
+
huggingface-hub==0.23.4
|
26 |
+
idna==3.7
|
27 |
+
itsdangerous==2.2.0
|
28 |
+
Jinja2==3.1.4
|
29 |
+
keras==3.4.1
|
30 |
+
libclang==18.1.1
|
31 |
+
Markdown==3.6
|
32 |
+
markdown-it-py==3.0.0
|
33 |
+
MarkupSafe==2.1.5
|
34 |
+
mdurl==0.1.2
|
35 |
+
ml-dtypes==0.3.2
|
36 |
+
namex==0.0.8
|
37 |
+
numpy==1.26.4
|
38 |
+
opt-einsum==3.3.0
|
39 |
+
optree==0.11.0
|
40 |
+
orjson==3.10.5
|
41 |
+
packaging==24.1
|
42 |
+
protobuf==4.25.3
|
43 |
+
pydantic==2.7.4
|
44 |
+
pydantic_core==2.18.4
|
45 |
+
Pygments==2.18.0
|
46 |
+
python-dotenv==1.0.1
|
47 |
+
python-multipart==0.0.9
|
48 |
+
PyYAML==6.0.1
|
49 |
+
regex==2024.5.15
|
50 |
+
requests==2.32.3
|
51 |
+
rich==13.7.1
|
52 |
+
safetensors==0.4.3
|
53 |
+
shellingham==1.5.4
|
54 |
+
six==1.16.0
|
55 |
+
sniffio==1.3.1
|
56 |
+
starlette==0.37.2
|
57 |
+
tensorboard==2.16.2
|
58 |
+
tensorboard-data-server==0.7.2
|
59 |
+
tensorflow==2.16.2
|
60 |
+
tensorflow-io-gcs-filesystem==0.37.0
|
61 |
+
termcolor==2.4.0
|
62 |
+
tf_keras==2.16.0
|
63 |
+
tokenizers==0.19.1
|
64 |
+
tqdm==4.66.4
|
65 |
+
transformers==4.42.3
|
66 |
+
typer==0.12.3
|
67 |
+
typing_extensions==4.12.2
|
68 |
+
ujson==5.10.0
|
69 |
+
urllib3==2.2.2
|
70 |
+
uvicorn==0.30.1
|
71 |
+
uvloop==0.19.0
|
72 |
+
watchfiles==0.22.0
|
73 |
+
websockets==12.0
|
74 |
+
Werkzeug==3.0.3
|
75 |
+
wrapt==1.16.0
|
responsesBaseModels/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
__pycache__
|
responsesBaseModels/InterpretadorResponseBaseModel.py
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pydantic import BaseModel
|
2 |
+
|
3 |
+
|
4 |
+
class InterpretadorResponseBaseModel(BaseModel):
|
5 |
+
resposta: str
|
responsesBaseModels/__init__.py
ADDED
File without changes
|
responsesBaseModels/__pycache__/InterpretadorResponseBaseModel.cpython-310.pyc
ADDED
Binary file (464 Bytes). View file
|
|
responsesBaseModels/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (177 Bytes). View file
|
|
static/controllers/InterpretadorController.js
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
class InterpretadorController {
|
2 |
+
cadastrarTexto = () => {
|
3 |
+
CadastroDeTextoPage();
|
4 |
+
}
|
5 |
+
|
6 |
+
/**
|
7 |
+
*
|
8 |
+
* @param {Interpretador} interpretador
|
9 |
+
*/
|
10 |
+
fazerPergunta = (interpretador) => {
|
11 |
+
PerguntaPage(interpretador);
|
12 |
+
}
|
13 |
+
|
14 |
+
inserirTexto = () => {
|
15 |
+
/**
|
16 |
+
* @type {HTMLTextAreaElement}
|
17 |
+
*/
|
18 |
+
const textoElement = document.getElementById("texto");
|
19 |
+
|
20 |
+
const texto = textoElement.value;
|
21 |
+
const interpretador = new Interpretador(texto);
|
22 |
+
PerguntaPage(interpretador);
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
*
|
27 |
+
* @param {Interpretador} interpretador
|
28 |
+
*/
|
29 |
+
mostrarQuestoes = (interpretador) => {
|
30 |
+
QuestoesPage(interpretador);
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
*
|
35 |
+
* @param {Interpretador} interpretador
|
36 |
+
*/
|
37 |
+
mostrarTexto = (interpretador) => {
|
38 |
+
TextoPage(interpretador);
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
*
|
43 |
+
* @param {Interpretador} interpretador
|
44 |
+
* @returns {Promise<void>}
|
45 |
+
*/
|
46 |
+
responder = async (interpretador) => {
|
47 |
+
/**
|
48 |
+
* @type {HTMLTextAreaElement}
|
49 |
+
*/
|
50 |
+
const perguntaElement = document.getElementById("pergunta");
|
51 |
+
|
52 |
+
const texto = interpretador.getTexto();
|
53 |
+
const pergunta = perguntaElement.value;
|
54 |
+
const service = new InterpretadorService();
|
55 |
+
await service.responder(texto, pergunta).then((response) => {
|
56 |
+
const resposta = response.resposta;
|
57 |
+
const questao = new Questao(pergunta, resposta);
|
58 |
+
interpretador.adicionarQuestao(questao);
|
59 |
+
this.mostrarQuestoes(interpretador);
|
60 |
+
}).catch((error) => {
|
61 |
+
ErroPage("Não foi possível obter resposta.", interpretador);
|
62 |
+
});
|
63 |
+
|
64 |
+
}
|
65 |
+
}
|
static/main.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
const interpretadorController = new InterpretadorController();
|
2 |
+
interpretadorController.cadastrarTexto();
|
static/models/Interpretador.js
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
class Interpretador {
|
2 |
+
/**
|
3 |
+
* @type {string}
|
4 |
+
* @private
|
5 |
+
*/
|
6 |
+
texto;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @type {Questao[]}
|
10 |
+
*/
|
11 |
+
questoes;
|
12 |
+
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
* @param {string} texto
|
16 |
+
*/
|
17 |
+
constructor(texto) {
|
18 |
+
this.texto = texto;
|
19 |
+
this.questoes = [];
|
20 |
+
}
|
21 |
+
|
22 |
+
getTexto = () => {
|
23 |
+
return this.texto;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
*
|
28 |
+
* @param {Questao} questao
|
29 |
+
*/
|
30 |
+
adicionarQuestao = (questao) => {
|
31 |
+
this.questoes.push(questao);
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @returns {Questao[]}
|
36 |
+
*/
|
37 |
+
getQuestoes = () => {
|
38 |
+
return this.questoes.reverse();
|
39 |
+
}
|
40 |
+
}
|
static/models/InterpretadorRequest.js
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
class InterpretadorRequest {
|
2 |
+
/**
|
3 |
+
* @type {string}
|
4 |
+
*/
|
5 |
+
texto;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* @type {string}
|
9 |
+
*/
|
10 |
+
pergunta;
|
11 |
+
|
12 |
+
/**
|
13 |
+
*
|
14 |
+
* @param {string} texto
|
15 |
+
* @param {string} pergunta
|
16 |
+
*/
|
17 |
+
constructor(texto, pergunta) {
|
18 |
+
this.texto = texto;
|
19 |
+
this.pergunta = pergunta;
|
20 |
+
}
|
21 |
+
}
|
static/models/InterpretadorResponse.js
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
class InterpretadorResponse {
|
2 |
+
/**
|
3 |
+
* @type {string}
|
4 |
+
*/
|
5 |
+
resposta;
|
6 |
+
}
|
static/models/Questao.js
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
class Questao {
|
2 |
+
/**
|
3 |
+
* @type {string}
|
4 |
+
* @private
|
5 |
+
*/
|
6 |
+
pergunta;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @type {string}
|
10 |
+
* @private
|
11 |
+
*/
|
12 |
+
resposta;
|
13 |
+
|
14 |
+
/**
|
15 |
+
*
|
16 |
+
* @param {string} pergunta
|
17 |
+
* @param {string} resposta
|
18 |
+
*/
|
19 |
+
constructor(pergunta, resposta) {
|
20 |
+
this.pergunta = pergunta;
|
21 |
+
this.resposta = resposta;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* @returns {string}
|
27 |
+
*/
|
28 |
+
getPergunta = () => {
|
29 |
+
return this.pergunta;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
*
|
34 |
+
* @returns {string}
|
35 |
+
*/
|
36 |
+
getResposta = () => {
|
37 |
+
return this.resposta;
|
38 |
+
}
|
39 |
+
}
|
static/services/InterpretadorService.js
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
class InterpretadorService {
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @param {string} texto
|
5 |
+
* @param {string} pergunta
|
6 |
+
* @returns {Promise<InterpretadorResponse>}
|
7 |
+
*/
|
8 |
+
responder = async (texto, pergunta) => {
|
9 |
+
const request = new InterpretadorRequest(texto, pergunta);
|
10 |
+
const options = new Options("POST", request);
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @type {Promise<InterpretadorResponse>}
|
14 |
+
*/
|
15 |
+
const response = await fetch(urlApi, options).then((response) => {
|
16 |
+
return response.json();
|
17 |
+
}).catch((error) => {
|
18 |
+
console.log(error);
|
19 |
+
});
|
20 |
+
|
21 |
+
return response;
|
22 |
+
}
|
23 |
+
}
|
static/style.css
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
:root {
|
2 |
+
--azul: rgb(0, 0, 255);
|
3 |
+
--azul-claro: rgb(128, 128, 255);
|
4 |
+
--azul-escuro: rgb(0, 0, 128);
|
5 |
+
--azul-muito-claro: rgb(191, 191, 255);
|
6 |
+
--azul-muito-escuro: rgb(0, 0, 64);
|
7 |
+
--azul-pouco-claro: rgb(64, 64, 255);
|
8 |
+
--azul-pouco-escuro: rgb(0, 0, 191);
|
9 |
+
--vermelho: rgb(255, 0, 0);
|
10 |
+
--verde: rgb(0, 128, 0);
|
11 |
+
--familha-da-fonte: serif;
|
12 |
+
--margem-grande: 8px 8px 8px 8px;
|
13 |
+
--margem-pequena: 4px 4px 4px 4px;
|
14 |
+
--padding-texto: 4px 8px 4px 8px;
|
15 |
+
--tamanho-da-fonte: 16px;
|
16 |
+
}
|
17 |
+
|
18 |
+
body {
|
19 |
+
display: flex;
|
20 |
+
flex-direction: column;
|
21 |
+
align-items: center;
|
22 |
+
justify-content: center;
|
23 |
+
margin: 0;
|
24 |
+
min-height: 100vh;
|
25 |
+
min-width: 100vw;
|
26 |
+
}
|
27 |
+
|
28 |
+
button {
|
29 |
+
background-color: var(--azul-escuro);
|
30 |
+
border: none;
|
31 |
+
color: white;
|
32 |
+
cursor: pointer;
|
33 |
+
font-family: var(--familha-da-fonte);
|
34 |
+
font-size: var(--tamanho-da-fonte);
|
35 |
+
margin: var(--margem-grande);
|
36 |
+
padding: var(--padding-texto);
|
37 |
+
}
|
38 |
+
|
39 |
+
button:hover {
|
40 |
+
background-color: var(--azul-pouco-escuro);
|
41 |
+
}
|
42 |
+
|
43 |
+
button:active {
|
44 |
+
background-color: var(--azul);
|
45 |
+
}
|
46 |
+
|
47 |
+
h1 {
|
48 |
+
font-family: var(--familha-da-fonte);
|
49 |
+
}
|
50 |
+
|
51 |
+
label {
|
52 |
+
font-family: var(--familha-da-fonte);
|
53 |
+
font-size: var(--tamanho-da-fonte);
|
54 |
+
margin: var(--margem-grande);
|
55 |
+
padding: var(--padding-texto);
|
56 |
+
}
|
57 |
+
|
58 |
+
p {
|
59 |
+
font-family: var(--familha-da-fonte);
|
60 |
+
font-size: var(--tamanho-da-fonte);
|
61 |
+
margin: var(--margem-grande);
|
62 |
+
padding: var(--padding-texto);
|
63 |
+
width: 512px;
|
64 |
+
}
|
65 |
+
|
66 |
+
textarea {
|
67 |
+
font-family: var(--familha-da-fonte);
|
68 |
+
font-size: var(--tamanho-da-fonte);
|
69 |
+
margin: var(--margem-grande);
|
70 |
+
padding: var(--padding-texto);
|
71 |
+
}
|
72 |
+
|
73 |
+
.buttons {
|
74 |
+
display: flex;
|
75 |
+
flex-direction: row;
|
76 |
+
align-items: center;
|
77 |
+
justify-content: center;
|
78 |
+
margin: var(--margem-grande);
|
79 |
+
}
|
80 |
+
|
81 |
+
.erro {
|
82 |
+
color: var(--vermelho);
|
83 |
+
font-family: var(--familha-da-fonte);
|
84 |
+
}
|
85 |
+
|
86 |
+
.espera {
|
87 |
+
background-color: var(--azul-claro);
|
88 |
+
color: white;
|
89 |
+
font-family: var(--familha-da-fonte);
|
90 |
+
font-size: var(--tamanho-da-fonte);
|
91 |
+
margin: var(--margem-grande);
|
92 |
+
padding: var(--margem-grande);
|
93 |
+
text-align: center;
|
94 |
+
width: 512px;
|
95 |
+
}
|
96 |
+
|
97 |
+
.pergunta {
|
98 |
+
display: flex;
|
99 |
+
flex-direction: column;
|
100 |
+
align-items: center;
|
101 |
+
justify-content: center;
|
102 |
+
margin: var(--margem-grande);
|
103 |
+
}
|
104 |
+
|
105 |
+
.questao {
|
106 |
+
display: flex;
|
107 |
+
flex-direction: column;
|
108 |
+
align-items: center;
|
109 |
+
justify-content: center;
|
110 |
+
margin: var(--margem-grande);
|
111 |
+
}
|
112 |
+
|
113 |
+
.questao:hover {
|
114 |
+
background-color: var(--azul-muito-claro);
|
115 |
+
}
|
116 |
+
|
117 |
+
.questoes {
|
118 |
+
display: flex;
|
119 |
+
flex-direction: column;
|
120 |
+
align-items: center;
|
121 |
+
justify-content: center;
|
122 |
+
margin: var(--margem-grande);
|
123 |
+
}
|
static/utils/Api.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
const urlApi = "http://0.0.0.0:7860";
|
static/utils/Options.js
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
class Options {
|
2 |
+
/**
|
3 |
+
* @typedef OptionHeader
|
4 |
+
* @property {string} "Content-Type"
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* @type {string}
|
9 |
+
*/
|
10 |
+
method
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @type {OptionHeader}
|
14 |
+
*/
|
15 |
+
headers;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @type {string}
|
19 |
+
*/
|
20 |
+
body
|
21 |
+
|
22 |
+
/**
|
23 |
+
*
|
24 |
+
* @param {string} method
|
25 |
+
* @param {Object} dados
|
26 |
+
*/
|
27 |
+
constructor(method, dados) {
|
28 |
+
this.method = method;
|
29 |
+
this.headers = {"Content-type": "application/json"};
|
30 |
+
this.body = JSON.stringify(dados);
|
31 |
+
}
|
32 |
+
}
|
static/views/components/Button.js
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
*
|
3 |
+
* @param {string} textContent
|
4 |
+
* @param {() => void} action
|
5 |
+
*/
|
6 |
+
function Button(textContent, action) {
|
7 |
+
const button = document.createElement("button");
|
8 |
+
button.textContent = textContent;
|
9 |
+
button.addEventListener("click", action);
|
10 |
+
return button;
|
11 |
+
}
|
static/views/components/ErroComponent.js
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
*
|
3 |
+
* @param {string} textContent
|
4 |
+
* @returns {HTMLHeadingElement}
|
5 |
+
*/
|
6 |
+
function ErroComponent(textContent) {
|
7 |
+
const component = document.createElement("h1");
|
8 |
+
component.className = "erro";
|
9 |
+
component.textContent = textContent;
|
10 |
+
return component;
|
11 |
+
}
|
static/views/components/EsperaComponent.js
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @returns {HTMLDivElement}
|
3 |
+
*/
|
4 |
+
function EsperaComponent() {
|
5 |
+
const component = document.createElement("div");
|
6 |
+
component.className = "espera";
|
7 |
+
component.textContent = "Aguardando resposta";
|
8 |
+
return component;
|
9 |
+
}
|
static/views/components/Heading.js
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
*
|
3 |
+
* @param {string} textContent
|
4 |
+
* @returns {HTMLHeadingElement}
|
5 |
+
*/
|
6 |
+
function Heading(textContent) {
|
7 |
+
const heading = document.createElement("h1");
|
8 |
+
heading.textContent = textContent;
|
9 |
+
return heading;
|
10 |
+
}
|
static/views/components/Label.js
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
*
|
3 |
+
* @param {string} textContent
|
4 |
+
* @param {string} id
|
5 |
+
* @returns {HTMLLabelElement}
|
6 |
+
*/
|
7 |
+
function Label(textContent, id) {
|
8 |
+
const label = document.createElement("label");
|
9 |
+
label.textContent = textContent;
|
10 |
+
label.htmlFor = id;
|
11 |
+
return label;
|
12 |
+
}
|
static/views/components/Paragraph.js
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
*
|
3 |
+
* @param {string} textContent
|
4 |
+
* @returns {HTMLParagraphElement}
|
5 |
+
*/
|
6 |
+
function Paragraph(textContent) {
|
7 |
+
const paragraph = document.createElement('p');
|
8 |
+
paragraph.innerHTML = textContent;
|
9 |
+
return paragraph;
|
10 |
+
}
|
static/views/components/TextArea.js
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
*
|
3 |
+
* @param {string} id
|
4 |
+
* @param {number} rows
|
5 |
+
* @param {number} columns
|
6 |
+
* @returns {HTMLTextAreaElement}
|
7 |
+
*/
|
8 |
+
function TextArea(id, rows, columns) {
|
9 |
+
const textArea = document.createElement("textarea");
|
10 |
+
textArea.id = id;
|
11 |
+
textArea.rows = rows;
|
12 |
+
textArea.cols = columns;
|
13 |
+
return textArea;
|
14 |
+
}
|
static/views/containers/Buttons.js
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
*
|
3 |
+
* @param {HTMLButtonElement[]} buttons
|
4 |
+
* @returns {HTMLDivElement}
|
5 |
+
*/
|
6 |
+
function Buttons(buttons) {
|
7 |
+
const container = document.createElement("div");
|
8 |
+
container.className = "buttons";
|
9 |
+
|
10 |
+
buttons.forEach((button) => {
|
11 |
+
container.appendChild(button);
|
12 |
+
});
|
13 |
+
|
14 |
+
return container;
|
15 |
+
}
|
static/views/containers/PerguntasContainer.js
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
*
|
3 |
+
* @param {string} label
|
4 |
+
* @param {string} id
|
5 |
+
* @param {string} className
|
6 |
+
* @param {number} rows
|
7 |
+
* @param {number} columns
|
8 |
+
* @returns {HTMLDivElement}
|
9 |
+
*/
|
10 |
+
function PerguntasContainer(label, id, className, rows, columns) {
|
11 |
+
const container = document.createElement("div");
|
12 |
+
container.className = className;
|
13 |
+
container.appendChild(Label(label, id));
|
14 |
+
container.appendChild(TextArea(id, rows, columns));
|
15 |
+
return container;
|
16 |
+
}
|
static/views/containers/QuestaoContainer.js
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
*
|
3 |
+
* @param {Questao} questao
|
4 |
+
* @returns {HTMLDivElement}
|
5 |
+
*/
|
6 |
+
function QuestaoContainer(questao) {
|
7 |
+
const container = document.createElement("div");
|
8 |
+
container.className = "questao";
|
9 |
+
const pergunta = questao.getPergunta();
|
10 |
+
const resposta = questao.getResposta();
|
11 |
+
const perguntaParagraph = Paragraph(`<strong>Pergunta: </strong>${pergunta}`);
|
12 |
+
const respostaParagraph = Paragraph(`<strong>Resposta: </strong>${resposta}`);
|
13 |
+
container.appendChild(perguntaParagraph);
|
14 |
+
container.appendChild(respostaParagraph);
|
15 |
+
return container;
|
16 |
+
}
|
static/views/containers/QuestoesContainer.js
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
*
|
3 |
+
* @param {QuestoesContainer[]} questoesContainer
|
4 |
+
* @returns {HTMLDivElement}
|
5 |
+
*/
|
6 |
+
function QuestoesContainer(questoesContainer) {
|
7 |
+
const container = document.createElement("div");
|
8 |
+
container.className = "questoes";
|
9 |
+
|
10 |
+
questoesContainer.forEach((questaoContainer) => {
|
11 |
+
container.appendChild(questaoContainer);
|
12 |
+
});
|
13 |
+
|
14 |
+
return container;
|
15 |
+
}
|
static/views/containers/TextoContainer.js
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
*
|
3 |
+
* @param {string} texto
|
4 |
+
* @returns {HTMLDivElement}
|
5 |
+
*/
|
6 |
+
function TextoContainer(texto) {
|
7 |
+
const container = document.createElement("div");
|
8 |
+
container.className = "texto";
|
9 |
+
const paragraphs = texto.split('\n');
|
10 |
+
|
11 |
+
paragraphs.forEach((paragraph) => {
|
12 |
+
const paragraphElement = Paragraph(paragraph)
|
13 |
+
container.appendChild(paragraphElement);
|
14 |
+
});
|
15 |
+
|
16 |
+
return container;
|
17 |
+
}
|
static/views/pages/CadastroDeTextoPage.js
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function CadastroDeTextoPage() {
|
2 |
+
const controller = new InterpretadorController();
|
3 |
+
|
4 |
+
/**
|
5 |
+
* @type {HTMLElement[]}
|
6 |
+
*/
|
7 |
+
const elements = [
|
8 |
+
Heading("Digite ou cole um texto"),
|
9 |
+
TextArea("texto", 16, 64),
|
10 |
+
Button("Submeter texto", controller.inserirTexto)
|
11 |
+
];
|
12 |
+
|
13 |
+
const page = Page();
|
14 |
+
|
15 |
+
elements.forEach((element) => {
|
16 |
+
page.appendChild(element);
|
17 |
+
});
|
18 |
+
}
|
static/views/pages/ErroPage.js
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
*
|
3 |
+
* @param {string} mensagem
|
4 |
+
* @param {Interpretador} interpretador
|
5 |
+
*/
|
6 |
+
function ErroPage(mensagem, interpretador) {
|
7 |
+
const controller = new InterpretadorController();
|
8 |
+
|
9 |
+
function fazerPergunta() {
|
10 |
+
controller.fazerPergunta(interpretador);
|
11 |
+
}
|
12 |
+
|
13 |
+
function reverTexto() {
|
14 |
+
controller.mostrarTexto(interpretador);
|
15 |
+
}
|
16 |
+
|
17 |
+
function mostrarQuestoes() {
|
18 |
+
controller.mostrarQuestoes(interpretador);
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @type {HTMLElement[]}
|
23 |
+
*/
|
24 |
+
const elements = [
|
25 |
+
ErroComponent(mensagem),
|
26 |
+
Buttons([
|
27 |
+
Button("Fazer Pergunta", fazerPergunta),
|
28 |
+
Button("Rever Texto", reverTexto),
|
29 |
+
Button("Mostrar Questoes Feitas", mostrarQuestoes),
|
30 |
+
Button("Escolher Outro Texto", controller.cadastrarTexto)
|
31 |
+
])
|
32 |
+
];
|
33 |
+
|
34 |
+
const page = Page();
|
35 |
+
|
36 |
+
elements.forEach((element) => {
|
37 |
+
page.appendChild(element);
|
38 |
+
});
|
39 |
+
}
|
static/views/pages/Page.js
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @returns {HTMLBodyElement}
|
3 |
+
*/
|
4 |
+
function Page() {
|
5 |
+
const page = document.getElementsByTagName("body")[0];
|
6 |
+
page.innerHTML = '';
|
7 |
+
return page;
|
8 |
+
}
|
static/views/pages/PerguntaPage.js
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
*
|
3 |
+
* @param {Interpretador} interpretador
|
4 |
+
*/
|
5 |
+
function PerguntaPage(interpretador) {
|
6 |
+
const controller = new InterpretadorController();
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @type {HTMLElement[]}
|
10 |
+
*/
|
11 |
+
let elements = [];
|
12 |
+
|
13 |
+
function addElements() {
|
14 |
+
elements.forEach((element) => {
|
15 |
+
page.appendChild(element);
|
16 |
+
});
|
17 |
+
}
|
18 |
+
|
19 |
+
function responder() {
|
20 |
+
const esperaComponent = EsperaComponent();
|
21 |
+
elements.unshift(esperaComponent);
|
22 |
+
addElements();
|
23 |
+
controller.responder(interpretador);
|
24 |
+
}
|
25 |
+
|
26 |
+
function mostrarTexto() {
|
27 |
+
controller.mostrarTexto(interpretador);
|
28 |
+
}
|
29 |
+
|
30 |
+
function mostrarQuestoes() {
|
31 |
+
controller.mostrarQuestoes(interpretador);
|
32 |
+
}
|
33 |
+
|
34 |
+
elements = [
|
35 |
+
Heading("Digite uma Pergunta"),
|
36 |
+
TextArea("pergunta", 2, 64),
|
37 |
+
Buttons([
|
38 |
+
Button("Obter Resposta", responder),
|
39 |
+
Button("Rever Texto", mostrarTexto),
|
40 |
+
Button("Mostrar Questoes Feitas", mostrarQuestoes),
|
41 |
+
Button("Escolher Outro Texto", controller.cadastrarTexto)
|
42 |
+
])
|
43 |
+
];
|
44 |
+
|
45 |
+
const page = Page();
|
46 |
+
|
47 |
+
addElements();
|
48 |
+
}
|
static/views/pages/QuestoesPage.js
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
*
|
3 |
+
* @param {Interpretador} interpretador
|
4 |
+
*/
|
5 |
+
function QuestoesPage(interpretador) {
|
6 |
+
const questoes = interpretador.getQuestoes();
|
7 |
+
const controller = new InterpretadorController();
|
8 |
+
|
9 |
+
function fazerPergunta() {
|
10 |
+
controller.fazerPergunta(interpretador);
|
11 |
+
}
|
12 |
+
|
13 |
+
function reverTexto() {
|
14 |
+
controller.mostrarTexto(interpretador);
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @type {HTMLDivElement[]}
|
19 |
+
*/
|
20 |
+
const questoesContainer = [];
|
21 |
+
|
22 |
+
questoes.forEach((questao) => {
|
23 |
+
const questaoContainer = QuestaoContainer(questao);
|
24 |
+
questoesContainer.push(questaoContainer);
|
25 |
+
});
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @type {HTMLElement[]}
|
29 |
+
*/
|
30 |
+
const elements = [
|
31 |
+
Heading("Lista de Questões Feitas"),
|
32 |
+
QuestoesContainer(questoesContainer),
|
33 |
+
Buttons([
|
34 |
+
Button("Fazer Outra Pergunta", fazerPergunta),
|
35 |
+
Button("Rever texto", reverTexto),
|
36 |
+
Button("Escolher Outro Texto", controller.cadastrarTexto)
|
37 |
+
])
|
38 |
+
];
|
39 |
+
|
40 |
+
const page = Page();
|
41 |
+
|
42 |
+
elements.forEach((element) => {
|
43 |
+
page.appendChild(element);
|
44 |
+
});
|
45 |
+
}
|
static/views/pages/TextoPage.js
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
*
|
3 |
+
* @param {Interpretador} interpretador
|
4 |
+
*/
|
5 |
+
function TextoPage(interpretador) {
|
6 |
+
const controller = new InterpretadorController();
|
7 |
+
|
8 |
+
function fazerPergunta() {
|
9 |
+
controller.fazerPergunta(interpretador);
|
10 |
+
}
|
11 |
+
|
12 |
+
function mostrarQuestoes() {
|
13 |
+
controller.mostrarQuestoes(interpretador);
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @type {HTMLElement[]}
|
18 |
+
*/
|
19 |
+
const elements = [
|
20 |
+
Heading("Texto"),
|
21 |
+
TextoContainer(interpretador.getTexto()),
|
22 |
+
Buttons([
|
23 |
+
Button("Fazer Pergunta", fazerPergunta),
|
24 |
+
Button("Mostrar Questoes Feitas", mostrarQuestoes),
|
25 |
+
Button("Escolher Outro Texto", controller.cadastrarTexto)
|
26 |
+
])
|
27 |
+
];
|
28 |
+
|
29 |
+
const page = Page();
|
30 |
+
|
31 |
+
elements.forEach((element) => {
|
32 |
+
page.appendChild(element);
|
33 |
+
});
|
34 |
+
}
|
templates/index.html
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<link rel="stylesheet" href="/static/style.css">
|
7 |
+
<title>Interpretador de Texto</title>
|
8 |
+
</head>
|
9 |
+
<body>
|
10 |
+
<script src="/static/utils/Api.js"></script>
|
11 |
+
<script src="/static/utils/Options.js"></script>
|
12 |
+
<script src="/static/models/Interpretador.js"></script>
|
13 |
+
<script src="/static/models/InterpretadorRequest.js"></script>
|
14 |
+
<script src="/static/models/InterpretadorResponse.js"></script>
|
15 |
+
<script src="/static/models/Questao.js"></script>
|
16 |
+
<script src="/static/services/InterpretadorService.js"></script>
|
17 |
+
<script src="/static/controllers/InterpretadorController.js"></script>
|
18 |
+
<script src="/static/views/components/Button.js"></script>
|
19 |
+
<script src="/static/views/components/ErroComponent.js"></script>
|
20 |
+
<script src="/static/views/components/EsperaComponent.js"></script>
|
21 |
+
<script src="/static/views/components/Heading.js"></script>
|
22 |
+
<script src="/static/views/components/Label.js"></script>
|
23 |
+
<script src="/static/views/components/Paragraph.js"></script>
|
24 |
+
<script src="/static/views/components/TextArea.js"></script>
|
25 |
+
<script src="/static/views/containers/Buttons.js"></script>
|
26 |
+
<script src="/static/views/containers/PerguntasContainer.js"></script>
|
27 |
+
<script src="/static/views/containers/QuestaoContainer.js"></script>
|
28 |
+
<script src="/static/views/containers/QuestoesContainer.js"></script>
|
29 |
+
<script src="/static/views/containers/TextoContainer.js"></script>
|
30 |
+
<script src="/static/views/pages/Page.js"></script>
|
31 |
+
<script src="/static/views/pages/CadastroDeTextoPage.js"></script>
|
32 |
+
<script src="/static/views/pages/ErroPage.js"></script>
|
33 |
+
<script src="/static/views/pages/PerguntaPage.js"></script>
|
34 |
+
<script src="/static/views/pages/QuestoesPage.js"></script>
|
35 |
+
<script src="/static/views/pages/TextoPage.js"></script>
|
36 |
+
<script src="/static/main.js"></script>
|
37 |
+
</body>
|
38 |
+
</html>
|