|
From: Torbjorn T. <et...@us...> - 2005-07-25 07:54:28
|
Update of /cvsroot/jungerl/jungerl/lib/ysql/priv/docroot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14492/ysql/priv/docroot Added Files: Makefile blank.html desc_table.yaws error.yaws head.inc index.yaws login_post.yaws logout.yaws select.yaws tail.inc top.yaws use.yaws ysql.css Log Message: Adding YSQL, the Yaws SQL Browser. --- NEW FILE: head.inc --- <html> <head> <title>Yaws SQL Browser</title> <link rel="STYLESHEET" type="text/css" href="ysql.css"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body class="body"> <table border="0" cellpadding="0" cellspacing="0" width="99%"> <tbody> <tr> <td class=logo>Yaws SQL Browser</td> <td ><span class="current_database_txt">(current database is:</span> <span class="current_database">%%DB%%</span><span class="current_database_txt">)</span></td> <td align="right" valign="bottom" class="date">%%DATE%%</td> </tr> <tr> </tr> <tr> <td colspan="3" bgcolor="#919af5"><img src="blank.html" height="2"></td> </tr> </tbody> </table> <table border="0" cellpadding="2" cellspacing="0" width="99%"> <tbody> <tr> <td class="headerLinks" align="left"> <a href="/%%DTABLE_LNK%%" class="headerLinks" title="Describe table">%%DTABLE%%</a> </td> <td class="headerLinks" align="right"> <a href="/top.yaws" class="headerLinks" title="Show all Databases">Databases</a> | <a href="/%%TABLES%%" title="Show all tables" class="headerLinks">Tables</a> | <a href="/logout.yaws" class="headerLinks" title="Logout from YSQL">Logout</a> </td> </tr> </tbody> </table> --- NEW FILE: index.yaws --- <html> <head> <title>Yaws SQL Browser</title> <link rel="STYLESHEET" type="text/css" href="ysql.css"> </head> <body> <erl> out(A) -> {ehtml, [{form, [{method, post}, {action, "login_post.yaws"}], [{table,[{cellspacing, "5"}, {class, "login_table"}], [{tr, [], [{td, [{colspan, "2"}], {p, [{class, "logo"}], "Yaws SQL Browser"}}]}, {tr, [], [{td, [], {p, [], "Username:"}}, {td, [], {input, [{name, user}, {type, text}, {size, "20"}]}}]}, {tr, [], [{td, [], {p, [], "Password:"}}, {td, [], {input, [{name, password}, {type, password}, {size, "20"}]}}]}, {tr, [], [{td, [], {p, [], "ODBC DSN:"}}, % DSN = Data Source Name {td, [], {input, [{name, dsn}, {type, text}, {value, "myodbc3"}, {size, "20"}]}}]}, {tr, [], [{td, [], {p, [], ""}}, {td, [], {input, [{type, submit}, {value, "Login"}]}}]}]}]}]}. </erl> </body> </html> --- NEW FILE: desc_table.yaws --- <erl> -include("ysql.hrl"). out(A) -> H = A#arg.headers, C = H#headers.cookie, case yaws_api:find_cookie_val("ysql", C) of [] -> {redirect_local, {rel_path, "error.yaws?emsg="++ yaws_api:url_encode("No cookie info found!")}}; Cookie -> {ok, Y} = yaws_api:cookieval_to_opaque(Cookie), case queryvar(A, "table") of {ok, Table} -> case ysql:desc_table(Y, Table) of {ok, Y2, Res} -> yaws_api:replace_cookie_session(Cookie, Y2), [{ssi, "head.inc", "%%", [{"DATE", ysql:date()}, {"DB", ysql:db(Y2)}, {"TABLES", "use.yaws?db="++Y#ysql.db}, {"DTABLE", Table}, {"DTABLE_LNK", "desc_table.yaws?table="++Table} ]}, Res, {ssi, "tail.inc", "%%", []}]; Else -> ?elog("desc_table.yaws: ~p~n", [Else]), {redirect_local, {rel_path, "error.yaws?emsg="++ yaws_api:url_encode("Internal error: desc_table.yaws!")}} end; undefined -> {redirect_local, {rel_path, "error.yaws?emsg="++ yaws_api:url_encode("No Table selected!")}} end end. </erl> </body> </html> --- NEW FILE: login_post.yaws --- <erl> -include("ysql.hrl"). out(A) -> L = yaws_api:parse_post(A), ?elog("HERE 1: ~p~n", [L]), User = ysql:lk("user", L), Passwd = ysql:lk("password", L), Dsn = ysql:lk("dsn", L), case ysql:odbc_connect(User, Passwd, Dsn) of {ok, Odbc} -> Y = #ysql{odbc = Odbc}, Cookie = yaws_api:new_cookie_session(Y), [yaws_api:setcookie("ysql", Cookie, "/"), {redirect_local, {rel_path, "top.yaws"}}]; {error, Emsg} -> {redirect_local, {rel_path, "error.yaws?emsg="++ yaws_api:url_encode(Emsg)}} end. </erl> --- NEW FILE: Makefile --- ## ## Create a timestamp file as a result of checking ## the yaws-file, so that we don't have to re-compile ## everything, all the time. (Tobbe) ## .SUFFIXES: .yaws-TS .yaws all: $(shell echo *.yaws | sed 's/yaws/yaws-TS/g') clean: -rm *.yaws-TS %.yaws-TS: %.yaws p=`pwd`/../../include; \ yaws -check $< $$p || exit 1; \ touch $<-TS --- NEW FILE: tail.inc --- </body> </html> --- NEW FILE: top.yaws --- <erl> -include("ysql.hrl"). out(A) -> H = A#arg.headers, C = H#headers.cookie, case yaws_api:find_cookie_val("ysql", C) of [] -> {redirect_local, {rel_path, "error.yaws?emsg="++ yaws_api:url_encode("No cookie info found!")}}; Cookie -> {ok, Y} = yaws_api:cookieval_to_opaque(Cookie), case ysql:top(Y) of {ok, Y2, Res} -> yaws_api:replace_cookie_session(Cookie, Y2), [{ssi, "head.inc", "%%", [{"DATE", ysql:date()}, {"DB", ysql:db(Y2)}, {"DTABLE", ""}, {"DTABLE_LNK", ""} ]}, Res, {ssi, "tail.inc", "%%", []}]; Else -> ?elog("top.yaws: ~p~n", [Else]), {redirect_local, {rel_path, "error.yaws?emsg="++ yaws_api:url_encode("Internal error: top.yaws!")}} end end. </erl> </body> </html> --- NEW FILE: ysql.css --- *.login_table { position: relative; top: 5em; left: 30%; } *.databases { position: relative; top: 5em; left: 30%; } *.databases_title { position: relative; top: 4em; float: top; left: 30%; font-size: larger; color: blue; } *.current_database { font-size: smaller; color: blue; } *.current_database_txt { font-size: smaller; } *.tables { position: relative; top: 5em; left: 5%; } *.desc_table { position: relative; top: 5em; left: 5%; } *.sql_table { position: relative; top: 5em; left: 5%; } *.sql_table_name { position: relative; top: 4em; float: top; left: 5%; font-size: larger; color: blue; } *.sql_query { position: relative; top: 3em; float: top; left: 1%; font-size: smaller; font-style: italic; color: blue; } *.sql_table_submit { position: relative; top: 4em; float: top; left: 5%; } *.result_table { border-collapse: collapse; border: solid black; } *.result_table td { border: 1px solid red; padding: 5px; } *.table_head { font-weight: bold; } *.logo { font-size: larger; color: blue; } *.date { color: red; } --- NEW FILE: blank.html --- <html> <head></head> <body bgcolor="#ffffff"> </body> </html> --- NEW FILE: use.yaws --- <erl> -include("ysql.hrl"). out(A) -> H = A#arg.headers, C = H#headers.cookie, case yaws_api:find_cookie_val("ysql", C) of [] -> {redirect_local, {rel_path, "error.yaws?emsg="++ yaws_api:url_encode("No cookie info found!")}}; Cookie -> {ok, Y} = yaws_api:cookieval_to_opaque(Cookie), case queryvar(A, "db") of {ok, Db} -> case ysql:use(Y, Db) of {ok, Y2, Res} -> yaws_api:replace_cookie_session(Cookie, Y2), [{ssi, "head.inc", "%%", [{"DATE", ysql:date()}, {"DB", ysql:db(Y2)}, {"TABLES", "use.yaws?db="++Db}, {"DTABLE", ""}, {"DTABLE_LNK", ""}]}, Res, {ssi, "tail.inc", "%%", []}]; Else -> ?elog("use.yaws: ~p~n", [Else]), {redirect_local, {rel_path, "error.yaws?emsg="++ yaws_api:url_encode("Internal error: use.yaws!")}} end; undefined -> {redirect_local, {rel_path, "error.yaws?emsg="++ yaws_api:url_encode("No Database selected!")}} end end. </erl> </body> </html> --- NEW FILE: error.yaws --- <html> <head> </head> <body> <h1>ERROR !!</h1> <erl> out(A) -> case queryvar(A, emsg) of {ok, Val} -> {html, nl2br(yaws_api:url_decode(Val))}; _ -> {html, "No error message found!"} end. nl2br([$\n|T]) -> [$<,$b,$r,$>|nl2br(T)]; nl2br([H|T]) -> [H|nl2br(T)]; nl2br([]) -> []. </erl> </body> </html> --- NEW FILE: logout.yaws --- <erl> -include("ysql.hrl"). out(A) -> H = A#arg.headers, C = H#headers.cookie, case yaws_api:find_cookie_val("ysql", C) of [] -> {redirect_local, {rel_path, "error.yaws?emsg="++ yaws_api:url_encode("No cookie info found!")}}; Cookie -> {ok, Y} = yaws_api:cookieval_to_opaque(Cookie), case ysql:logout(Y) of ok -> yaws_api:delete_cookie_session(Cookie), {redirect_local, {rel_path, "index.yaws"}}; Else -> ?elog("logout.yaws: ~p~n", [Else]), {redirect_local, {rel_path, "error.yaws?emsg="++ yaws_api:url_encode("Internal error: logout.yaws!")}} end end. </erl> </body> </html> --- NEW FILE: select.yaws --- <erl> -include("ysql.hrl"). out(A) -> H = A#arg.headers, C = H#headers.cookie, case yaws_api:find_cookie_val("ysql", C) of [] -> {redirect_local, {rel_path, "error.yaws?emsg="++ yaws_api:url_encode("No cookie info found!")}}; Cookie -> {ok, Y} = yaws_api:cookieval_to_opaque(Cookie), L = yaws_api:parse_post(A), Selected = ysql:selected(L), Where = ysql:where(L), OrderBy = ysql:lk("orderby", L, ""), ?elog("select: selected=~p , where=~p orderby=~p~n", [Selected, Where, OrderBy]), case ysql:select(Y, Selected, Where, OrderBy) of {ok, Y2, Res} -> yaws_api:replace_cookie_session(Cookie, Y2), [{ssi, "head.inc", "%%", [{"DATE", ysql:date()}, {"DB", ysql:db(Y2)}, {"TABLES", "use.yaws?db="++Y#ysql.db}, {"DTABLE", Y#ysql.table}, {"DTABLE_LNK", "desc_table.yaws?table="++Y#ysql.table} ]}, Res, {ssi, "tail.inc", "%%", []}]; Else -> ?elog("desc_table.yaws: ~p~n", [Else]), {redirect_local, {rel_path, "error.yaws?emsg="++ yaws_api:url_encode("Internal error: desc_table.yaws!")}} end end. </erl> </body> </html> |