tonton_web 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/QA.md +73 -0
- data/bin/tauth +88 -0
- data/bin/tonton-web +35 -0
- data/building.md +19 -0
- data/example/app.rb +18 -0
- data/example/config.ru +12 -0
- data/lib/tonton_web/auth.rb +73 -0
- data/lib/tonton_web.rb +1 -0
- data/readme.md +83 -0
- data/views/layout.erb +25 -0
- metadata +51 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 5fb4d6653fbc38244766810bd8773369a64c14b49a5007814829d98decc94af1
|
|
4
|
+
data.tar.gz: e3ba09e7b332166a9921749f49414cdec5a238e6b1b4416b0b1b88b0bd86c5e7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c8c7042cfb40609e265fe276690b2400d953453647c3ce6ca4aebd0f0b666b0cad9f5d3cd513f9d9a4d3b8f7dbc47287f5058a9f3ca83a0f9eebd80fbfb016d4
|
|
7
|
+
data.tar.gz: ea62ef794b1a5f69344247ed5c14c01cca2b2c4d710f3079b072aa40a5c688ba97be2774589053b85799f1be2abbed6a122bd27c6415399fe36ce4af882086da
|
data/QA.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Perguntas e respostas
|
|
2
|
+
|
|
3
|
+
## Qual é a origem do nome TonTon?
|
|
4
|
+
|
|
5
|
+
É um nome fofo.
|
|
6
|
+
|
|
7
|
+
## Por que a logo do TonTon é um coelho?
|
|
8
|
+
|
|
9
|
+
É uma logo fofa.
|
|
10
|
+
|
|
11
|
+
## Quantas pessoas desenvolvem o TonTon?
|
|
12
|
+
|
|
13
|
+
Majoritariamente uma: eu.
|
|
14
|
+
|
|
15
|
+
Prazer, seruna.
|
|
16
|
+
|
|
17
|
+
Mas o projeto recebeu uma contribuição recente da vanel. Obrigado vanel.
|
|
18
|
+
|
|
19
|
+
## Como o TonTon é mantido?
|
|
20
|
+
|
|
21
|
+
TonTon não gera nenhuma renda.
|
|
22
|
+
|
|
23
|
+
A despesa se dá pela mensalidade do serviço de servidor virtual para hospedar o site e pela anuidade do domínio.
|
|
24
|
+
|
|
25
|
+
Os custos são cobertos por mim e pela vanel. Obrigado vanel.
|
|
26
|
+
|
|
27
|
+
## E se eu, por algum motivo, quiser ajudar financeiramente a manter o projeto?
|
|
28
|
+
|
|
29
|
+
Se você é brasileiro, PIX:
|
|
30
|
+
|
|
31
|
+
02196960209
|
|
32
|
+
|
|
33
|
+
Se você não é brasileiro, [Ko-fi](https://ko-fi.com/seruna1).
|
|
34
|
+
|
|
35
|
+
Obrigado.
|
|
36
|
+
|
|
37
|
+
## O TonTon é feito inteiramente em Ruby?
|
|
38
|
+
|
|
39
|
+
Não, mas a maioria do código relacionado à web é em Ruby.
|
|
40
|
+
|
|
41
|
+
Espera-se que tenha algumas coisas em C, outra linguagem familiar para o desenvolvedor.
|
|
42
|
+
|
|
43
|
+
## Por que o TonTon é feito em Ruby?
|
|
44
|
+
|
|
45
|
+
- É a linguagem de programação preferida do desenvolvedor.
|
|
46
|
+
|
|
47
|
+
- Um excelente ecossistema.
|
|
48
|
+
|
|
49
|
+
- Legível, parece natural, ajuda o TonTon a ser simples e extensível. Também ajuda a manter a qualidade de vida do desenvolvedor.
|
|
50
|
+
|
|
51
|
+
## Ruby não é uma linguagem morta?
|
|
52
|
+
|
|
53
|
+
Acredito que não seja o caso. Mas certamente não é tão popular quanto Javascript ou Python.
|
|
54
|
+
|
|
55
|
+
## Posso contribuir com o TonTon sem programar em Ruby?
|
|
56
|
+
|
|
57
|
+
Pode.
|
|
58
|
+
|
|
59
|
+
## Quão ativo é o desenvolvimento do TonTon
|
|
60
|
+
|
|
61
|
+
Desenvolvo em meu tempo livre.
|
|
62
|
+
|
|
63
|
+
## Por que Sinatra? Por que não Ruby on Rails?
|
|
64
|
+
|
|
65
|
+
Simplicidade no escopo do projeto.
|
|
66
|
+
|
|
67
|
+
## O TonTon é para grupos de estudo?
|
|
68
|
+
|
|
69
|
+
Sim.
|
|
70
|
+
|
|
71
|
+
## TonTon só seria usado para cursos de computação?
|
|
72
|
+
|
|
73
|
+
Não necessariamente.
|
data/bin/tauth
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#! /usr/bin/ruby
|
|
2
|
+
|
|
3
|
+
require 'sod'
|
|
4
|
+
|
|
5
|
+
require_relative '../lib/tonton_web/auth'
|
|
6
|
+
require 'io/console'
|
|
7
|
+
|
|
8
|
+
class CreateTable < Sod::Action
|
|
9
|
+
on "--create-table"
|
|
10
|
+
|
|
11
|
+
def call(*)
|
|
12
|
+
context.tauth.create_tables
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class CreateUser < Sod::Command
|
|
17
|
+
handle "create-user"
|
|
18
|
+
|
|
19
|
+
class Username < Sod::Action
|
|
20
|
+
on "--username", argument: "USERNAME"
|
|
21
|
+
|
|
22
|
+
def call(username) = context.input[:username] = username
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class Name < Sod::Action
|
|
26
|
+
on "--name", argument: "NAME"
|
|
27
|
+
|
|
28
|
+
def call(name) = context.input[:name] = name
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
class Email < Sod::Action
|
|
32
|
+
on "--email", argument: "EMAIL"
|
|
33
|
+
|
|
34
|
+
def call(email) = context.input[:email] = email
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
on Username
|
|
38
|
+
on Name
|
|
39
|
+
on Email
|
|
40
|
+
|
|
41
|
+
def call
|
|
42
|
+
context.input[:password] = IO::console.getpass("User password: ")
|
|
43
|
+
|
|
44
|
+
context.tauth.create_user(**context.input)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class DeleteUser < Sod::Action
|
|
49
|
+
on "--delete-user", argument: "USER_ID"
|
|
50
|
+
|
|
51
|
+
def call(user_id)
|
|
52
|
+
context.tauth.delete_user user_id
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
class Info < Sod::Command
|
|
57
|
+
handle "info"
|
|
58
|
+
|
|
59
|
+
description "Information about user."
|
|
60
|
+
|
|
61
|
+
class Username < Sod::Action
|
|
62
|
+
on "--username", argument: "TEXT"
|
|
63
|
+
|
|
64
|
+
def call text
|
|
65
|
+
puts context.tauth.find_user(username: text)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
on Username
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
tauth = TonTonWeb::Auth.new Dir.getwd
|
|
73
|
+
|
|
74
|
+
context = Sod::Context[tauth: tauth, input: {}]
|
|
75
|
+
|
|
76
|
+
cli = Sod.new(banner: "Tauth 0.0.0: TonTon Auth") do
|
|
77
|
+
on(CreateTable, context:)
|
|
78
|
+
|
|
79
|
+
on(CreateUser, context:)
|
|
80
|
+
|
|
81
|
+
on(DeleteUser, context:)
|
|
82
|
+
|
|
83
|
+
on(Info, context:)
|
|
84
|
+
|
|
85
|
+
on Sod::Prefabs::Actions::Help, self
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
cli.call
|
data/bin/tonton-web
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#! /usr/bin/ruby
|
|
2
|
+
|
|
3
|
+
require 'sod'
|
|
4
|
+
|
|
5
|
+
class New < Sod::Action
|
|
6
|
+
on "--new", argument: "NAME"
|
|
7
|
+
|
|
8
|
+
def call(name)
|
|
9
|
+
destination_root = Pathname.new name
|
|
10
|
+
|
|
11
|
+
destination_root.mkdir
|
|
12
|
+
|
|
13
|
+
(destination_root+'modules').mkdir
|
|
14
|
+
|
|
15
|
+
gem_root = Pathname.new(__FILE__).parent + '..'
|
|
16
|
+
|
|
17
|
+
for source in gem_root.glob('{example/*,*.md}')
|
|
18
|
+
destination = destination_root + source.basename
|
|
19
|
+
|
|
20
|
+
`cp #{source} #{destination}`
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
(destination_root+'views').mkdir
|
|
24
|
+
|
|
25
|
+
`cp -r #{gem_root+'views'} #{destination_root}`
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
cli = Sod.new(banner: "TonTon Web 0.0.0: TonTon utilitary for web apps") do
|
|
30
|
+
on(New)
|
|
31
|
+
|
|
32
|
+
on Sod::Prefabs::Actions::Help, self
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
cli.call
|
data/building.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Contruindo uma instância do TonTonWeb
|
|
2
|
+
|
|
3
|
+
Clone o repositório da aplicação princiapal (esse repositório).
|
|
4
|
+
|
|
5
|
+
Edite o arquivo de configuração Rack [config.ru]. O arquivo exemplo mapeia apenas a rota '/' para a aplicação principal. Adicione aplicações do projeto TonTon e mapeie elas para novas rotas.
|
|
6
|
+
|
|
7
|
+
Instale as dependências e inicie o servidor.
|
|
8
|
+
|
|
9
|
+
bundle install
|
|
10
|
+
|
|
11
|
+
bundle exec puma
|
|
12
|
+
|
|
13
|
+
É necessário que o shell tenha a variável de ambiente SESSION_SECRET definida.
|
|
14
|
+
|
|
15
|
+
UwU
|
|
16
|
+
|
|
17
|
+
## Módulos Ruby TonTon
|
|
18
|
+
|
|
19
|
+
Clone o repositório do módulo dentro da aplicação principal e o inclua no arquivo [config.ru].
|
data/example/app.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'gollum/app'
|
|
2
|
+
require 'sinatra/flash'
|
|
3
|
+
require "sqlite3"
|
|
4
|
+
require 'tonton_web'
|
|
5
|
+
|
|
6
|
+
class TonTonWeb::App < Sinatra::Base
|
|
7
|
+
set :host_authorization, { permitted_hosts: ['localhost', 'mytonton.com.br'] }
|
|
8
|
+
|
|
9
|
+
set :sessions, true
|
|
10
|
+
|
|
11
|
+
get '/' do
|
|
12
|
+
redirect "/readme.md"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
get '/:name' do
|
|
16
|
+
markdown File.read(params['name']), layout_engine: :erb, layout: true
|
|
17
|
+
end
|
|
18
|
+
end
|
data/example/config.ru
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
require 'pathname'
|
|
2
|
+
require 'sqlite3'
|
|
3
|
+
require 'bcrypt'
|
|
4
|
+
|
|
5
|
+
module TonTonWeb
|
|
6
|
+
User = Struct.new(:id, :name, :username, :email, :password_digest)
|
|
7
|
+
|
|
8
|
+
class Auth
|
|
9
|
+
attr_reader :root
|
|
10
|
+
|
|
11
|
+
def initialize root_path
|
|
12
|
+
@root = Pathname.new root_path
|
|
13
|
+
|
|
14
|
+
@db = SQLite3::Database.new(@root+ 'database.sqlite')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def create_tables
|
|
18
|
+
@db.execute "create table users (id integer primary key, name text, username text, email text, password_digest text);"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def create_user **options
|
|
22
|
+
name = options.fetch :name
|
|
23
|
+
username = options.fetch :username
|
|
24
|
+
email = options.fetch :email
|
|
25
|
+
password = options.fetch :password
|
|
26
|
+
|
|
27
|
+
# Assert user doesn't exists
|
|
28
|
+
|
|
29
|
+
hashed_password = BCrypt::Password.create(password)
|
|
30
|
+
|
|
31
|
+
@db.execute(
|
|
32
|
+
"insert into users (name, username, email, password_digest) values (?,?,?,?);",
|
|
33
|
+
[name, username, email, password]
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
return # Return user
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def delete_user id
|
|
40
|
+
@db.execute "delete from users where id = ?;", id
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def find_user **options
|
|
44
|
+
name = options[:name]
|
|
45
|
+
username = options[:username]
|
|
46
|
+
email = options[:email]
|
|
47
|
+
|
|
48
|
+
if not (name or username or email)
|
|
49
|
+
raise "No options to find user."
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
user = nil
|
|
53
|
+
|
|
54
|
+
user_query_template = "select id, name, username, email, password_digest from users where name = ? or username = ? or email = ?"
|
|
55
|
+
|
|
56
|
+
@db.execute(user_query_template, [name, username, email]) do |row|
|
|
57
|
+
user = TonTonWeb::User.new(*row)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
return user
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def authenticate username, password
|
|
64
|
+
user = find_user(username: username)
|
|
65
|
+
|
|
66
|
+
if BCrypt::Password.new(user.password_digest) == password
|
|
67
|
+
return user
|
|
68
|
+
else
|
|
69
|
+
return false
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
data/lib/tonton_web.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require_relative 'tonton_web/auth'
|
data/readme.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# TonTon
|
|
2
|
+
|
|
3
|
+
TonTon é uma antologia de softwares abertos, modulares e relacionados com tecnologia na educação e com aprendizado colaborativo. Esse repositório contém a aplicação web principal. <(^_^)>
|
|
4
|
+
|
|
5
|
+
O Ruby on Rails foi substituido pelo Sinatra. (⌐■_■)
|
|
6
|
+
|
|
7
|
+
As aplicações terão APIs para facilitar interfaces alternativas. Monte o seu TonTon. ( ͡° ᴥ ͡°)
|
|
8
|
+
|
|
9
|
+
[Building](building.md)
|
|
10
|
+
|
|
11
|
+
[Q&A](QA.md)
|
|
12
|
+
|
|
13
|
+
## TonTonWeb
|
|
14
|
+
|
|
15
|
+
Aplicação web principal, em Ruby, com um mecanismo de controle de usuários.
|
|
16
|
+
|
|
17
|
+
O gerenciamento é feito via linha de comando (utilitário tauth) e interface web.
|
|
18
|
+
|
|
19
|
+
O serviços são expostos via:
|
|
20
|
+
|
|
21
|
+
- API Ruby via Rack (para ser usada pela interface interna).
|
|
22
|
+
|
|
23
|
+
- API web (para ser usada por interfaces que não são escritas em Ruby).
|
|
24
|
+
|
|
25
|
+
O TonTonWeb tem uma versão [experimental](https://github.com/seruna-1/tonton) em Ruby on Rails, agora arquivada. (◡_◡)
|
|
26
|
+
|
|
27
|
+
Status: sem mecanismo de autenticação.
|
|
28
|
+
|
|
29
|
+
## TonTon-Gollum (wiki)
|
|
30
|
+
|
|
31
|
+
Uma extensão simples da wiki Gollum para suportar autenticação de usuário.
|
|
32
|
+
|
|
33
|
+
Status: testável.
|
|
34
|
+
|
|
35
|
+
Funcionalidades esperadas:
|
|
36
|
+
|
|
37
|
+
- Subdiretórios dos usuários editáveis apenas pelo próprio usuário.
|
|
38
|
+
|
|
39
|
+
## Tolls
|
|
40
|
+
|
|
41
|
+
Tonton Polls.
|
|
42
|
+
|
|
43
|
+
Aplicação Sinatra para gerenciamento de enquetes.
|
|
44
|
+
|
|
45
|
+
Status: não iniciado.
|
|
46
|
+
|
|
47
|
+
## Tofinn
|
|
48
|
+
|
|
49
|
+
Tokenizable File Interface.
|
|
50
|
+
|
|
51
|
+
Toffin é um modelo genérico de árvore de arquivos tokenizáveis e com um modelo integrado opcional de versionamento de arquivos.
|
|
52
|
+
|
|
53
|
+
Status: concepção. Duas implementações esperadas, uma em C (Coffin) e outra em Ruby (Torfinn). Há uma versão [experimental](https://github.com/seruna-1/toffin), em Ruby, abandonada.
|
|
54
|
+
|
|
55
|
+
## Totoki
|
|
56
|
+
|
|
57
|
+
Totoki é o plano de wiki futura para o TonTon usando a API do Toffin.
|
|
58
|
+
|
|
59
|
+
Totoki é inspirada pelo Gollum. Assim como o Gollum lida com frontend e tem a própria API separada (gollum-lib), o Totoki será a aplicação Sinatra com API wiki separada (totoki-lib).
|
|
60
|
+
|
|
61
|
+
Status: não iniciado.
|
|
62
|
+
|
|
63
|
+
## Tamire
|
|
64
|
+
|
|
65
|
+
TonTon Abstract Mathematical Introspective Representation (Tamire).
|
|
66
|
+
|
|
67
|
+
Tamire é uma biblioteca de para abstração de linguagem matemática em estruturas de objetos.
|
|
68
|
+
|
|
69
|
+
Teria duas implementações, uma em Ruby e outra em Javascript, cada uma com:
|
|
70
|
+
|
|
71
|
+
- Leitura de Asciimath para entrada.
|
|
72
|
+
|
|
73
|
+
- Renderização em SVG para saída.
|
|
74
|
+
|
|
75
|
+
- Representação em Json para entrada e saída.
|
|
76
|
+
|
|
77
|
+
Status: não iniciado.
|
|
78
|
+
|
|
79
|
+
## Tamires
|
|
80
|
+
|
|
81
|
+
Tamire Speaker (Tamires) é um módulo Javascript e uma aplicação Ruby para análise por pessoas cegas de estrutura matemática gerada pela Tamire.
|
|
82
|
+
|
|
83
|
+
Status: não iniciado.
|
data/views/layout.erb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<title>TonTon</title>
|
|
4
|
+
</head>
|
|
5
|
+
|
|
6
|
+
<body>
|
|
7
|
+
<header>
|
|
8
|
+
<nav>
|
|
9
|
+
<a href="/readme.md">Readme</a>
|
|
10
|
+
|
|
11
|
+
<a href="/building.md">Building</a>
|
|
12
|
+
|
|
13
|
+
<a href="/QA.md">Q&A</a>
|
|
14
|
+
</nav>
|
|
15
|
+
<header>
|
|
16
|
+
|
|
17
|
+
<%= yield %>
|
|
18
|
+
</body>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
const title = document.querySelector('title');
|
|
22
|
+
|
|
23
|
+
title.textContent = document.querySelector('h1').textContent;
|
|
24
|
+
</script>
|
|
25
|
+
</html>
|
metadata
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: tonton_web
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Mateus Cezário Barreto
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: TonTon Web app main parts
|
|
13
|
+
email: mateus.cezario.barreto@gmail.com
|
|
14
|
+
executables:
|
|
15
|
+
- tauth
|
|
16
|
+
- tonton-web
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- QA.md
|
|
21
|
+
- bin/tauth
|
|
22
|
+
- bin/tonton-web
|
|
23
|
+
- building.md
|
|
24
|
+
- example/app.rb
|
|
25
|
+
- example/config.ru
|
|
26
|
+
- lib/tonton_web.rb
|
|
27
|
+
- lib/tonton_web/auth.rb
|
|
28
|
+
- readme.md
|
|
29
|
+
- views/layout.erb
|
|
30
|
+
homepage: https://mytonton.com.br
|
|
31
|
+
licenses:
|
|
32
|
+
- MIT
|
|
33
|
+
metadata: {}
|
|
34
|
+
rdoc_options: []
|
|
35
|
+
require_paths:
|
|
36
|
+
- lib
|
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '0'
|
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
requirements: []
|
|
48
|
+
rubygems_version: 3.6.9
|
|
49
|
+
specification_version: 4
|
|
50
|
+
summary: TonTon Web app main parts
|
|
51
|
+
test_files: []
|