-
Notifications
You must be signed in to change notification settings - Fork 0
/
MenuInteractivo.hs
133 lines (109 loc) · 4.28 KB
/
MenuInteractivo.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
module MenuInteractivo
(
menuPrincipal
) where
import System.Exit
import System.Console.ANSI
import AnalisisSimples
import AnalisisTweets
main :: IO()
main = menuPrincipal
menuPrincipal :: IO()
menuPrincipal = do
clearScreen
putStrLn "Hola, bienvenido al wizard de TweeKell"
putStrLn "Menu principal:"
putStrLn "Pulse enter para comenzar o escriba alguna opción"
putStrLn "\ni: Información"
putStrLn "q: Salir"
option <- getLine
case option of
"i" -> menuInformacion
"q" -> exitSuccess
_ -> menu1
menuError :: IO()
menuError = do
putStrLn "Lo sentimos se ha producido un error"
exitSuccess
menuInformacion :: IO()
menuInformacion = do
clearScreen
putStrLn "TweeKell"
putStrLn "Análisis de los datos privados de una cuenta de Twitter con Haskell\n"
putStrLn "Desarrollado por Juan Arteaga Carmona\nProgramación Declarativa - Universidad de Sevilla"
putStrLn "La documentación oficial de la aplicación se encuentra en el documento Documentacion.pdf"
putStrLn "\n - Requisitos previos:"
putStrLn "Para poder utilizar este programa son necesarios los datos de la cuenta de Twitter en formato JSON.\nGeneralmente, estando logueado en Twitter viaje a:\n Ajustes -> Cuenta -> Mis datos de Twitter -> Introduzca su contraseña -> Pedir datos."
putStrLn "\nIMPORTANTE: Dependiendo de su cuenta es posible que el proceso de recolección de datos de Twitter\ntarde varios minutos, por lo que se recomienda descargar estos datos previamente.\n"
putStrLn "Ademas, si desea utilizar las funciones de mostrar imágenes y consultar su perfil será necesario que tenga instalado el navegador Firefox.\nConsulte el gestor de paquetes de su distribución para asegurarse de que lo tiene instalado."
putStrLn "\nq: Menu principal"
option <- getLine
case option of
"q" -> menuPrincipal
menu1 :: IO()
menu1 = do
clearScreen
putStrLn "Paso 1.1 - Preparar datos:"
putStrLn "\nq: Salir"
putStrLn "Escriba la ruta completa a la carpeta del archivo zip descomprimido (Sin la barra final): "
option <- getLine
case option of
"q" -> menuPrincipal
_ -> do
let ruta = option
menu2 ruta
menu2 :: String -> IO()
menu2 ruta = do
clearScreen
putStrLn "Paso 1.2 - Seleccionar el archivo a utilizar"
putStrLn "Estos son los archivos que puede seleccionar: account.js, profile.js, verified.js, phone-number.js, tweet.js"
putStrLn "q: Volver"
putStrLn "Escriba el nombre del archivo a utilizar: "
option <- getLine
case option of
"q" -> menu1
_ -> do
let archivo = option
print ruta
menu3 ruta archivo
menu3 :: String -> String -> IO()
menu3 ruta archivo = do
clearScreen
putStrLn "Paso 1.3 - Comprobación:"
putStrLn "q: Volver, Intro OK"
putStrLn "Asegurese de que la ruta introducida es correcta: "
let rutacompleta = ruta ++ "/" ++ archivo
print rutacompleta
option <- getLine
case option of
"q" -> menu1
_ -> menutipoAnalisis ruta archivo
menutipoAnalisis :: String -> String -> IO()
menutipoAnalisis ruta archivo = do
clearScreen
putStrLn "Paso 2 - Tipo de análisis:"
putStrLn "q: Volver, Intro OK\n"
putStrLn "Para el archivo seleccionado existen los siguientes tipos de análisis:"
let tipos = tipoAnalisis archivo
putStrLn $ unlines tipos
putStrLn "Por favor seleccione el tipo de análisis que desea realizar:\n"
option <- getLine
case option of
{-
1: Ver informacion
2: Abrir en navegador
-}
"1" -> AnalisisSimples.verInformacion ruta archivo
"2" -> AnalisisSimples.abrirNavegador ruta archivo
"3" -> AnalisisTweets.verTweets (ruta++"/"++archivo)
"4" -> AnalisisTweets.verRetweets (ruta++"/"++archivo)
"5" -> AnalisisTweets.tweetMasRT (ruta++"/"++archivo)
"6" -> AnalisisTweets.tweetMasMG (ruta++"/"++archivo)
"7" -> AnalisisTweets.idiomas (ruta++"/"++archivo)
"8" -> AnalisisSimples.verIconoPerfil (ruta++"/"++archivo)
tipoAnalisis :: String -> [String]
tipoAnalisis "account.js" = ["1: Ver informacion", "2: Abrir en navegador"]
tipoAnalisis "profile.js" = ["1: Ver informacion","8: Ver icono de perfil"]
tipoAnalisis "verified.js" = ["1: Ver informacion"]
tipoAnalisis "phone-number.js" = ["1: Ver informacion"]
tipoAnalisis "tweet.js" = ["3: Ver tweets", "4: Ver Retweets", "5: Tweet mas retweeteado","6: Tweet con más MG","7: Idiomas mas utilizados"]