hosthome 1.1.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/.gitattributes +8 -0
- data/.gitignore +127 -0
- data/LICENSE.md +674 -0
- data/README.md +23 -0
- data/main.py +3 -0
- data/src/__init__.py +0 -0
- data/src/app.py +128 -0
- data/src/auth.py +100 -0
- data/src/cli/archivo.txt +11 -0
- data/src/cli/ayuda.txt +7 -0
- data/src/cli/php/main.php +37 -0
- data/src/cli/ruby/mauhome/mauhome.rb +69 -0
- data/src/cli/ruby/mauhome.gemspec +22 -0
- data/src/data/README.md +13 -0
- data/src/data/users.json +3 -0
- data/src/static/css/auth.css +416 -0
- data/src/static/css/cuenta.css +84 -0
- data/src/static/css/style.css +377 -0
- data/src/static/css/utilities.css +232 -0
- data/src/static/images/auth/log.svg +1 -0
- data/src/static/images/auth/register.svg +1 -0
- data/src/static/images/cli.png +0 -0
- data/src/static/images/cloud.png +0 -0
- data/src/static/images/docs.png +0 -0
- data/src/static/images/favicon.png +0 -0
- data/src/static/images/logos/clojure.png +0 -0
- data/src/static/images/logos/csharp.png +0 -0
- data/src/static/images/logos/go.png +0 -0
- data/src/static/images/logos/node.png +0 -0
- data/src/static/images/logos/php.png +0 -0
- data/src/static/images/logos/python.png +0 -0
- data/src/static/images/logos/ruby.png +0 -0
- data/src/static/images/logos/scala.png +0 -0
- data/src/static/images/server.png +0 -0
- data/src/static/images/server2.png +0 -0
- data/src/static/images/server_secure.svg +1 -0
- data/src/static/js/auth.js +16 -0
- data/src/templates/README.md +3 -0
- data/src/templates/account.html +52 -0
- data/src/templates/auth.html +116 -0
- data/src/templates/docs.html +93 -0
- data/src/templates/extends/footer.html +22 -0
- data/src/templates/extends/navbar.html +17 -0
- data/src/templates/features.html +97 -0
- data/src/templates/index.html +144 -0
- metadata +86 -0
data/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# HostHome
|
|
2
|
+
Una web para hacer hosting
|
|
3
|
+
|
|
4
|
+
# TODO
|
|
5
|
+
|
|
6
|
+
* Terminar la web principal - Ayuda
|
|
7
|
+
* Terminar el AUTH
|
|
8
|
+
* Hacer los CLIs
|
|
9
|
+
* python
|
|
10
|
+
* CS - Ayuda
|
|
11
|
+
* NodeJS - Ayuda
|
|
12
|
+
* Ruby :: Queda por hacer deploy
|
|
13
|
+
* PHP
|
|
14
|
+
* Scala
|
|
15
|
+
* Clojure - Ayuda
|
|
16
|
+
* Hacer el systema del hosting
|
|
17
|
+
* Hacer que cadavez que vea el codigo no vomite
|
|
18
|
+
* Termninar la pagina de la cuenta y responsive
|
|
19
|
+
|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
* Empezar algun CLI
|
|
23
|
+
* Continuar con los docs
|
data/main.py
ADDED
data/src/__init__.py
ADDED
|
File without changes
|
data/src/app.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
from flask import Flask, render_template, request, redirect, url_for, session
|
|
2
|
+
|
|
3
|
+
from src.auth import CrearUsuario, HacerLogin, Usuario
|
|
4
|
+
|
|
5
|
+
app = Flask(__name__, static_url_path="/src/web/static")
|
|
6
|
+
app.secret_key = "myllavecitasecretita123"
|
|
7
|
+
|
|
8
|
+
@app.route("/")
|
|
9
|
+
def PaginaPrincipal():
|
|
10
|
+
|
|
11
|
+
usr = None
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
if session['user_id']:
|
|
15
|
+
usr = Usuario(session['user_id']).cojer()
|
|
16
|
+
if not usr["abierto"] == True:
|
|
17
|
+
usr = None
|
|
18
|
+
except Exception as e:
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
return render_template("index.html", user=usr)
|
|
22
|
+
|
|
23
|
+
@app.route("/account")
|
|
24
|
+
def Cuenta():
|
|
25
|
+
|
|
26
|
+
usr = None
|
|
27
|
+
|
|
28
|
+
try:
|
|
29
|
+
if session['user_id']:
|
|
30
|
+
usr = Usuario(session['user_id']).cojer()
|
|
31
|
+
if not usr["abierto"] == True:
|
|
32
|
+
return redirect(url_for('Auth'))
|
|
33
|
+
except Exception as e:
|
|
34
|
+
return redirect(url_for('Auth'))
|
|
35
|
+
|
|
36
|
+
return render_template("account.html", user=usr)
|
|
37
|
+
|
|
38
|
+
@app.route("/features")
|
|
39
|
+
def Features():
|
|
40
|
+
|
|
41
|
+
usr = None
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
if session['user_id']:
|
|
45
|
+
usr = Usuario(session['user_id']).cojer()
|
|
46
|
+
if not usr["abierto"] == True:
|
|
47
|
+
usr = None
|
|
48
|
+
except Exception as e:
|
|
49
|
+
pass
|
|
50
|
+
|
|
51
|
+
return render_template("features.html", user=usr)
|
|
52
|
+
|
|
53
|
+
@app.route("/docs")
|
|
54
|
+
def Docs():
|
|
55
|
+
|
|
56
|
+
usr = None
|
|
57
|
+
|
|
58
|
+
try:
|
|
59
|
+
if session['user_id']:
|
|
60
|
+
usr = Usuario(session['user_id']).cojer()
|
|
61
|
+
if not usr["abierto"] == True:
|
|
62
|
+
usr = None
|
|
63
|
+
except Exception as e:
|
|
64
|
+
pass
|
|
65
|
+
|
|
66
|
+
return render_template("docs.html", user=usr)
|
|
67
|
+
|
|
68
|
+
@app.route("/auth")
|
|
69
|
+
def Auth():
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
if session['user_id']:
|
|
73
|
+
if Usuario(session['user_id']).cojer()["abierto"] == True:
|
|
74
|
+
return redirect(url_for('PaginaPrincipal'))
|
|
75
|
+
except:
|
|
76
|
+
pass
|
|
77
|
+
|
|
78
|
+
return render_template("auth.html")
|
|
79
|
+
|
|
80
|
+
@app.route("/account/delete")
|
|
81
|
+
def EliminarCuenta():
|
|
82
|
+
|
|
83
|
+
usr = None
|
|
84
|
+
|
|
85
|
+
try:
|
|
86
|
+
if session['user_id']:
|
|
87
|
+
usr = Usuario(session['user_id']).eliminar()
|
|
88
|
+
except Exception as e:
|
|
89
|
+
pass
|
|
90
|
+
|
|
91
|
+
return redirect(url_for('PaginaPrincipal'))
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@app.route("/login", methods=["GET", "POST"])
|
|
95
|
+
def LogIn():
|
|
96
|
+
|
|
97
|
+
if request.method == "POST":
|
|
98
|
+
|
|
99
|
+
mail = request.form["email"]
|
|
100
|
+
psw = request.form["psw"]
|
|
101
|
+
|
|
102
|
+
usr = HacerLogin(mail, psw).ejecutar()
|
|
103
|
+
if usr == False:
|
|
104
|
+
return render_template("auth.html", err="Contraseña o email incorrectos")
|
|
105
|
+
session['user_id'] = usr
|
|
106
|
+
return redirect(url_for("Cuenta"))
|
|
107
|
+
|
|
108
|
+
return render_template("auth.html")
|
|
109
|
+
|
|
110
|
+
@app.route("/register", methods=["GET", "POST"])
|
|
111
|
+
def Registrarse():
|
|
112
|
+
|
|
113
|
+
if request.method == "POST":
|
|
114
|
+
|
|
115
|
+
mail = request.form["mail"]
|
|
116
|
+
psw = request.form["password"]
|
|
117
|
+
nombre = request.form["name"]
|
|
118
|
+
|
|
119
|
+
usr = CrearUsuario(nombre, psw, mail).crear()
|
|
120
|
+
if usr == False:
|
|
121
|
+
return render_template("auth.html", err="Ese email ya existe")
|
|
122
|
+
session['user_id'] = usr
|
|
123
|
+
return redirect(url_for("Cuenta"))
|
|
124
|
+
|
|
125
|
+
return redirect(url_for("Auth"))
|
|
126
|
+
|
|
127
|
+
def run():
|
|
128
|
+
app.run()
|
data/src/auth.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import json, random, datetime
|
|
2
|
+
|
|
3
|
+
def abrir():
|
|
4
|
+
with open("./src/data/users.json", "r") as f:
|
|
5
|
+
usrs = json.load(f)
|
|
6
|
+
|
|
7
|
+
return usrs
|
|
8
|
+
|
|
9
|
+
def cerrar(usrs):
|
|
10
|
+
with open("./src/data/users.json", "w") as f:
|
|
11
|
+
json.dump(usrs, f, indent=4)
|
|
12
|
+
|
|
13
|
+
class HacerLogin():
|
|
14
|
+
def __init__(self, email, psw):
|
|
15
|
+
self.email = email
|
|
16
|
+
self.psw = psw
|
|
17
|
+
|
|
18
|
+
def ejecutar(self):
|
|
19
|
+
usuarios = abrir()
|
|
20
|
+
|
|
21
|
+
if self.email in usuarios:
|
|
22
|
+
if usuarios[str(self.email)]["psw"] == self.psw:
|
|
23
|
+
usuarios[str(self.email)]["abierto"] = True
|
|
24
|
+
tk = CrearUsuario().tokenizar()
|
|
25
|
+
usuarios[str(self.email)]["cuentas"].append(tk)
|
|
26
|
+
cerrar(usuarios)
|
|
27
|
+
return str(tk)
|
|
28
|
+
return False
|
|
29
|
+
|
|
30
|
+
class Usuario():
|
|
31
|
+
|
|
32
|
+
def __init__(self, tk: str):
|
|
33
|
+
self.tk = tk
|
|
34
|
+
|
|
35
|
+
def cojer(self):
|
|
36
|
+
usuarios = abrir()
|
|
37
|
+
|
|
38
|
+
for usr in usuarios:
|
|
39
|
+
for token in usuarios[usr]["cuentas"]:
|
|
40
|
+
if self.tk == token:
|
|
41
|
+
return usuarios[usr]
|
|
42
|
+
return None
|
|
43
|
+
|
|
44
|
+
def eliminar(self):
|
|
45
|
+
usuarios = abrir()
|
|
46
|
+
|
|
47
|
+
for usr in usuarios:
|
|
48
|
+
for token in usuarios[usr]["cuentas"]:
|
|
49
|
+
if self.tk == token:
|
|
50
|
+
usuarios[usr]["abierto"] = False
|
|
51
|
+
# del usuarios[usr]["cuentas"][self.tk]
|
|
52
|
+
cerrar(usuarios)
|
|
53
|
+
|
|
54
|
+
class CrearUsuario():
|
|
55
|
+
def __init__(self, nombre: str=None, psw: str=None, mail: str=None):
|
|
56
|
+
self.nombre = nombre
|
|
57
|
+
self.psw = psw
|
|
58
|
+
self.mail = mail
|
|
59
|
+
|
|
60
|
+
def check(self, usuarios, token: str):
|
|
61
|
+
for tk in usuarios["cuentas"]:
|
|
62
|
+
if token == tk:
|
|
63
|
+
return False
|
|
64
|
+
|
|
65
|
+
def tokenizar(self):
|
|
66
|
+
usuarios = abrir()
|
|
67
|
+
token_valido = False
|
|
68
|
+
token = ""
|
|
69
|
+
|
|
70
|
+
while not token_valido:
|
|
71
|
+
token = str(random.randint(10000000, 90000000))
|
|
72
|
+
for usr in usuarios:
|
|
73
|
+
valido = self.check(usuarios[usr], token)
|
|
74
|
+
if not valido:
|
|
75
|
+
break
|
|
76
|
+
token_valido = True
|
|
77
|
+
|
|
78
|
+
return token
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def crear(self):
|
|
82
|
+
usuarios = abrir()
|
|
83
|
+
|
|
84
|
+
if not self.mail in usuarios:
|
|
85
|
+
|
|
86
|
+
usuarios[str(self.mail)] = {}
|
|
87
|
+
usuarios[str(self.mail)]["mail"] = self.mail
|
|
88
|
+
usuarios[str(self.mail)]["nombre"] = self.nombre
|
|
89
|
+
usuarios[str(self.mail)]["psw"] = self.psw
|
|
90
|
+
usuarios[str(self.mail)]["cuentas"] = []
|
|
91
|
+
tkN = self.tokenizar()
|
|
92
|
+
usuarios[str(self.mail)]["cuentas"].append(str(tkN))
|
|
93
|
+
usuarios[str(self.mail)]["abierto"] = True
|
|
94
|
+
now = datetime.datetime.now()
|
|
95
|
+
usuarios[str(self.mail)]["entrada"] = f"{now.day}/{now.month}/{now.year}"
|
|
96
|
+
|
|
97
|
+
cerrar(usuarios)
|
|
98
|
+
return str(tkN)
|
|
99
|
+
|
|
100
|
+
return False
|
data/src/cli/archivo.txt
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
main = mainTemp
|
|
2
|
+
repo = repoTemp
|
|
3
|
+
instalacion = instalacionTemp
|
|
4
|
+
|
|
5
|
+
--- ADVERTENCIA
|
|
6
|
+
BAJO NINGUN CONCEPTO SE PUEDE MOVER ESTE ARCHIVO O EDITARLO
|
|
7
|
+
SI TENEIS ALGUN PROBLEMA PONERLO EN (https://github.com/maubg-debug/host/issues)
|
|
8
|
+
Y SI TENEIS ALGO QUE MEJORAR PONERLO AQUI (https://github.com/maubg-debug/host/pulls)
|
|
9
|
+
|
|
10
|
+
SI EL ARCIHVO PARA "main" ESTA INCORECTO NO SE EJECUTARA, SI EL REPO ESTA MAL NO SE EJECUTARA
|
|
11
|
+
---
|
data/src/cli/ayuda.txt
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
$args = $_SERVER["argv"];
|
|
3
|
+
function empezar($verbose) {
|
|
4
|
+
if ($verbose) {
|
|
5
|
+
echo "con verbose\n";
|
|
6
|
+
}
|
|
7
|
+
echo "empezando";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function ayuda() {
|
|
11
|
+
echo "ayuda";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (count($args) > 1) {
|
|
15
|
+
if (count($args) == 3) {
|
|
16
|
+
if ($args[1] == "empezar") {
|
|
17
|
+
if ($args[2] == "-v" or $args[2] == "--verbose") {
|
|
18
|
+
empezar(true);
|
|
19
|
+
exit();
|
|
20
|
+
} else {
|
|
21
|
+
echo "Argumento invalido :: ". $args[2] ." :: Porfavor pon \"php hothome -h\"";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
} else if ($args[1] == "empezar") {
|
|
25
|
+
empezar(false);
|
|
26
|
+
exit();
|
|
27
|
+
} else if ($args[1] == "-h" or $args[1] == "--help") {
|
|
28
|
+
ayuda();
|
|
29
|
+
exit();
|
|
30
|
+
} else {
|
|
31
|
+
echo "Porfavor mete un argumento.\nPuedes poner :: php hosthome -h";
|
|
32
|
+
exit();
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
echo "Porfavor mete un argumento.\nPuedes poner :: php hosthome -h";
|
|
36
|
+
exit();
|
|
37
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require 'optparse'
|
|
2
|
+
require "uri"
|
|
3
|
+
|
|
4
|
+
@verbose = false
|
|
5
|
+
|
|
6
|
+
@ayuda = File.open("./src/cli/ayuda.txt", "r").read
|
|
7
|
+
@texto = File.open("./src/cli/archivo.txt", "r").read
|
|
8
|
+
|
|
9
|
+
@repo = ""
|
|
10
|
+
@main = ""
|
|
11
|
+
@ins = ""
|
|
12
|
+
|
|
13
|
+
OptionParser.new do |opts|
|
|
14
|
+
opts.on("-h", "--help", "Enseña el comando de ayuda") do
|
|
15
|
+
puts @ayuda
|
|
16
|
+
exit
|
|
17
|
+
end
|
|
18
|
+
opts.on("-v", "--verbose", "te dice lo que esta creando") do
|
|
19
|
+
@verbose = true
|
|
20
|
+
end
|
|
21
|
+
opts.on("empezar", "Empezar la instalacion") do
|
|
22
|
+
|
|
23
|
+
while true # Archivo principal
|
|
24
|
+
puts "Pon donde estara el archivo principal * :: (Tiene que terminar con .rb)"
|
|
25
|
+
main = gets
|
|
26
|
+
if main == ""
|
|
27
|
+
next
|
|
28
|
+
elsif !main.end_with?(".rb")
|
|
29
|
+
end
|
|
30
|
+
@main = main
|
|
31
|
+
break
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
while true # Repo (Github, Bitbucket)
|
|
35
|
+
puts "Pon la url del repositorio (GitHub o BitBucket) * :: "
|
|
36
|
+
repo = gets
|
|
37
|
+
if repo == ""
|
|
38
|
+
next
|
|
39
|
+
end
|
|
40
|
+
urls = URI.extract(repo)
|
|
41
|
+
if urls.length == 1
|
|
42
|
+
if repo.start_with?("https://github.com/") or repo.start_with?("https://bitbucket.org/")
|
|
43
|
+
@repo = repo
|
|
44
|
+
break
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
@texto.gsub! 'mainTemp', @main
|
|
50
|
+
@texto.gsub! 'repoTemp', @repo
|
|
51
|
+
@texto.gsub! 'instalacionTemp', "bundle install"
|
|
52
|
+
|
|
53
|
+
if @verbose == true
|
|
54
|
+
puts "Creando archivo en ruta padre ..."
|
|
55
|
+
File.open(".host.home", "w") {
|
|
56
|
+
|file| file.puts @texto
|
|
57
|
+
}
|
|
58
|
+
sleep(1)
|
|
59
|
+
puts "Escribiendo ..."
|
|
60
|
+
sleep(1)
|
|
61
|
+
puts "Ya esta"
|
|
62
|
+
exit
|
|
63
|
+
else
|
|
64
|
+
File.open(".host.home", "w") {
|
|
65
|
+
|file| file.puts @texto
|
|
66
|
+
}
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end.parse!
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Gem::Specification.new do |s|
|
|
2
|
+
s.name = 'hosthome'
|
|
3
|
+
s.version = '1.1.0'
|
|
4
|
+
s.platform = Gem::Platform::RUBY
|
|
5
|
+
s.summary = 'El CLI para HostHome'
|
|
6
|
+
s.description = "Creado para poder hacer host en HostHome"
|
|
7
|
+
s.authors = ['Maubg']
|
|
8
|
+
|
|
9
|
+
s.homepage = 'http://github.com/maubg-debug/host'
|
|
10
|
+
s.files = Dir.glob("{lib,bin}/**/*")
|
|
11
|
+
s.require_path = 'lib'
|
|
12
|
+
|
|
13
|
+
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
14
|
+
f.match(%r{^(test|s|features)/})
|
|
15
|
+
end
|
|
16
|
+
s.bindir = "exe"
|
|
17
|
+
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
18
|
+
s.require_paths = ["lib"]
|
|
19
|
+
|
|
20
|
+
["new", "application_name", "--database=postgresql"]
|
|
21
|
+
|
|
22
|
+
end
|
data/src/data/README.md
ADDED
data/src/data/users.json
ADDED