From 1a824b893dbc02ad5ce962d4ec33aeff765bdb5f Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 14 Jan 2011 14:27:03 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added=20"Format=20SQL"=20as=20default=20Bun?= =?UTF-8?q?dle=20to=20scope=20Input=20Field/Query=20Editor=20which=20make?= =?UTF-8?q?=20usage=20of=20an=20online=20service=20to=20validate=20and=20f?= =?UTF-8?q?ormat=20the=20current=20query=20or=20selection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Format SQL.spBundle/command.plist | 184 +++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 SharedSupport/Default Bundles/Format SQL.spBundle/command.plist (limited to 'SharedSupport/Default Bundles/Format SQL.spBundle/command.plist') diff --git a/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist b/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist new file mode 100644 index 00000000..219cc2c7 --- /dev/null +++ b/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist @@ -0,0 +1,184 @@ + + + + + author + Hans-Jörg Bibiko + category + Query Editor + command + +# check if connected to the internet and if server is up +connected=$(/sbin/ping -t 3 -c 1 -on www.dpriver.com 2> /dev/null | grep 'icmp' | wc -l) +if [ $connected -eq "0" ]; then + echo "<font color=red>You are probably not connected to the internet or http://www.dpriver.com/ server is down.</font>" + exit $SP_BUNDLE_EXIT_SHOW_AS_HTML_TOOLTIP +fi + +# send SQL to www.dpriver.com and replace the formatted SQL string in first responder; if a parser error occurred +# show error message and try to jump to the error +cat <<HTML +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <base href="http://www.dpriver.com/pp/"> + <title>Connecting www.dpriver.com</title> + <script> + function lookForResult() { + if(document.all.outputsql.value.length > 8) { + if(document.all.errorhint.style.display == "inline") { + var errormes = document.all.outputsql.value; + var re = /.*?\(\d+\s*,\s*(\d+)\).*/; + re.exec(errormes); + var pos = parseInt(RegExp.\$1) - 1; + re = /.*?(\d+).*/; + re.exec('$SP_SELECTED_TEXT_RANGE'); + var offset = parseInt(RegExp.\$1); + pos = pos + offset; + alert(document.all.outputsql.value); + window.system.setSelectedTextRange(pos+''); + } else { + var txt = document.all.outputsql.value; + var len = txt.length; + window.system.setSelectedTextRange('$SP_SELECTED_TEXT_RANGE'); + window.system.insertText(txt.slice(0,len-2)); + } + window.system.closeHTMLOutputWindow(); + } else { + setTimeout("lookForResult()",50); + } + } + + function waitForResult() { + window.system.suppressExceptionAlert(); + setTimeout("lookForResult()",50); + } + </script> + <script language="JavaScript" type="text/javascript" src="pp.js"></script> +</head> +<body onload='window.resizeTo(300,200);SQLFMT.format(document.all.sp_submit);waitForResult()'> +<div id="retvalues"></div> +<p><b>Copyright &copy; 2001-2010 Gudu Software<br>All Rights Reserved<br><a href="mailto:support@dpriver.com">Contact US</a></b></p> +<br><br><br><br><br> +<p align=right>Please wait…</p> +<div class="page-container-1" style="display:none;"> + <div id="container"> + <div id="wrapper"> + <div id="content"> + <form id="SqlFmtForm" name="frm_sqlformat" method="post" action="/cgi-bin/ppserver" onsubmit="return false;"> + <div id="secondpanel"> + <div id="sp_database"> + <label class="desc" style="display:inline;">Database</label> + <select name="dbvendor"> + <option value="mysql" selected>MySQL</option> + </select> + <label class="desc" style="display:inline;padding:0 0 0px 40px; border:0px solid;">Output:</label> + <select name="outputfmt"> + <option value="SQL" selected>SQL(Text)</option> + </select> + </div> + </div> + <div id="sqlpanel"> + <div id="sp_inputsql"> + <textarea id ="inputsql" name="inputsql" cols="1" rows="1" wrap="off"> + `cat` + </textarea> + </div> + <div id="sp_submit"> + <input type="button" id="btnformat" name="print" value="Format SQL" onclick="SQLFMT.format(this)" value="Format SQL"> + <label style="display:none;">(Time used: <span id="timestamp">0</span> seconds)</label> + </div> + <div id="sp_submit" style="text-align:left;"> + </div> + <label id="errorhint" class="desc" style="color:#DF0000 !important;display:none;"> + Can't format input sql, make sure there is no syntax error and select correct database. + <a href="" style="display:none;">OR Report a bug of this sql beautifier</a> + </label> + <iframe id="ioutputsql" ></iframe> + <div id="sp_outputsql" style="display:none;"> + <textarea id = "outputsql" name="outputsql" cols="80" rows="15" wrap="off" > + </textarea> + </div> + <div id="sp_errormsg" style="display:none;"> + Error message goes to here! + </div> + </div> + <div id="formatoptions"> + <select name="keywordcs"> + <option value="Uppercase" selected >Uppercase</option> + <option value="Lowercase" >Lowercase</option> + <option value="InitCap" >InitCap</option> + <option value="Unchanged" >Unchanged</option> + </select> + <select name="identifiercs"> + <option value="Uppercase" >Uppercase</option> + <option value="Lowercase" selected >Lowercase</option> + <option value="InitCap" >InitCap</option> + <option value="Unchanged" >Unchanged</option> + <option value="initcapeachword" >Init cap each word</option> + </select> + <select name="functioncs"> + <option value="Uppercase" >Uppercase</option> + <option value="Lowercase" >Lowercase</option> + <option value="InitCap" selected >InitCap</option> + <option value="Unchanged" >Unchanged</option> + </select> + <input type="radio" name="lnbrwithcomma" value="after" checked > After + <input type="radio" name="lnbrwithcomma" value="before" > Before + <input type="radio" name="lnbrwithcomma" value= "beforewithspace" > Before with space + <input type="radio" name="liststyle" value="stack" checked>Stacked + <input type="radio" name="liststyle" value="nostack">Not Stacked + <input type="radio" name="salign" value="sleft" checked> Align left + <input type="radio" name="salign" value="sright" > Align right + <input type="checkbox" name="andorunderwhere" value="yes" checked> And/Or under Where + <input type="checkbox" name="removelnbr" value="yes" checked> Remove Linebreak before beautify + <input type="checkbox" name="trimquotechar" value="yes"> Trim Quoted Char of Each Line quoted char of eachline: <input type="text" name="quotechar" value= "&#34" size = 5 > + <input type="checkbox" name="compactmode" value="yes"> Compact the output of sql output + <input type="text" name="maxlenincm" value= "80" size = 5 > + </div> + <input type="hidden" name="clientid" value="4149-9094-8133-2031" /> + </form> + </div> + </div> + </div> +</div> + +</body> +</html> +HTML + + contact + znvy@ovovxb.qr + description + Send the current query or selection to www.dpriver.com and replace the current query or selection of the first responder by the server's formatted output. If a parser error occurred alert that error and tries to jump to the error location. + +Version 1.0 + input + selectedtext + input_fallback + currentquery + internalKeyEquivalent + + characters + T + keyCode + 17 + modifierFlags + 1835008 + + keyEquivalent + ^~@t + name + Format SQL + output + showashtml + scope + inputfield + tooltip + Send query or selection to www.dpriver.com to insert the SQL statement formatted + uuid + 36E1F94D-D6C4-460A-A663-C694AF85E099 + isDefaultBundle + + + -- cgit v1.2.3 From c352ef02ae0e81496c9db2b8973a8cdd43669366 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 14 Jan 2011 16:25:50 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed=20issue=20for=20default=20Bundles=20i?= =?UTF-8?q?f=20category=20or=20key=20equivalent=20was=20changed=20by=20the?= =?UTF-8?q?=20user=20=E2=80=A2=20improved=20Format=20SQL=20Bundle=20-=20ad?= =?UTF-8?q?ded=20checking=20for=20empty=20passed=20SQL=20string=20-=20chan?= =?UTF-8?q?ged=20category=20to=20Format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Default Bundles/Format SQL.spBundle/command.plist | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'SharedSupport/Default Bundles/Format SQL.spBundle/command.plist') diff --git a/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist b/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist index 219cc2c7..f6472de5 100644 --- a/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist +++ b/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist @@ -5,11 +5,19 @@ author Hans-Jörg Bibiko category - Query Editor + Format command + +# check for empty STDIN +SQL=$(cat) +if [ -z "$SQL" ]; then + echo "No SQL statements passed." + exit $SP_BUNDLE_EXIT_SHOW_AS_TEXT_TOOLTIP +fi + # check if connected to the internet and if server is up -connected=$(/sbin/ping -t 3 -c 1 -on www.dpriver.com 2> /dev/null | grep 'icmp' | wc -l) +connected=$(/sbin/ping -t 5 -c 1 -on www.dpriver.com 2> /dev/null | grep 'icmp' | wc -l) if [ $connected -eq "0" ]; then echo "<font color=red>You are probably not connected to the internet or http://www.dpriver.com/ server is down.</font>" exit $SP_BUNDLE_EXIT_SHOW_AS_HTML_TOOLTIP @@ -81,7 +89,7 @@ cat <<HTML <div id="sqlpanel"> <div id="sp_inputsql"> <textarea id ="inputsql" name="inputsql" cols="1" rows="1" wrap="off"> - `cat` + $SQL </textarea> </div> <div id="sp_submit"> -- cgit v1.2.3 From fa8cf4d15f95b0d3db90311c252b2398e9e51345 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 19 Jan 2011 23:41:41 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added=20to=20"Format=20SQL"=20Bundle=20comm?= =?UTF-8?q?and=20to=20display=20once=20an=20alert=20for=20the=20very=20fir?= =?UTF-8?q?st=20usage=20that=20this=20command=20sends=20the=20SQL=20statem?= =?UTF-8?q?ent(s)=20to=20an=20online=20service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Default Bundles/Format SQL.spBundle/command.plist | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'SharedSupport/Default Bundles/Format SQL.spBundle/command.plist') diff --git a/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist b/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist index f6472de5..1459d7a6 100644 --- a/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist +++ b/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist @@ -23,6 +23,17 @@ if [ $connected -eq "0" ]; then exit $SP_BUNDLE_EXIT_SHOW_AS_HTML_TOOLTIP fi +# show info alert about sending the SQL statements to an online service +if [ ! -e infoShowed ]; then + touch infoShowed + osascript -e 'tell app "Sequel Pro" to display dialog "This command will send the SQL statement(s) - unencrypted - to an online service (http://www.dpriver.com). Please consider this before sending confidential data!\n\nThis message will only be displayed once." with icon caution' 2> 1 + if [ `cat 1 | wc -c` -ne 0 ]; then + rm -f 1 + exit $SP_BUNDLE_EXIT_NONE + fi + rm -f 1 +fi + # send SQL to www.dpriver.com and replace the formatted SQL string in first responder; if a parser error occurred # show error message and try to jump to the error cat <<HTML -- cgit v1.2.3 From 9823aec95fef0ce2407530a52befea408922c4da Mon Sep 17 00:00:00 2001 From: Bibiko Date: Thu, 20 Jan 2011 13:05:13 +0000 Subject: =?UTF-8?q?=E2=80=A2=20do=20not=20remove=20line=20breaks=20in=20be?= =?UTF-8?q?forehand=20for=20"Format=20SQL"=20Bundle=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SharedSupport/Default Bundles/Format SQL.spBundle/command.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedSupport/Default Bundles/Format SQL.spBundle/command.plist') diff --git a/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist b/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist index 1459d7a6..c9458332 100644 --- a/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist +++ b/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist @@ -150,7 +150,7 @@ cat <<HTML <input type="radio" name="salign" value="sleft" checked> Align left <input type="radio" name="salign" value="sright" > Align right <input type="checkbox" name="andorunderwhere" value="yes" checked> And/Or under Where - <input type="checkbox" name="removelnbr" value="yes" checked> Remove Linebreak before beautify + <input type="checkbox" name="removelnbr" value="no" checked> Remove Linebreak before beautify <input type="checkbox" name="trimquotechar" value="yes"> Trim Quoted Char of Each Line quoted char of eachline: <input type="text" name="quotechar" value= "&#34" size = 5 > <input type="checkbox" name="compactmode" value="yes"> Compact the output of sql output <input type="text" name="maxlenincm" value= "80" size = 5 > -- cgit v1.2.3 From 1e346a2cb316886baaa516ebda9142a9b556446b Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 21 Jan 2011 15:53:07 +0000 Subject: =?UTF-8?q?=E2=80=A2=20updated=20syntax=20highlighting=20and=20com?= =?UTF-8?q?pletion=20suggestions=20due=20to=205.5=20additions=20=E2=80=A2?= =?UTF-8?q?=20improved=20"Format=20SQL"=20connection=20detection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SharedSupport/Default Bundles/Format SQL.spBundle/command.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedSupport/Default Bundles/Format SQL.spBundle/command.plist') diff --git a/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist b/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist index c9458332..13e86145 100644 --- a/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist +++ b/SharedSupport/Default Bundles/Format SQL.spBundle/command.plist @@ -17,7 +17,7 @@ if [ -z "$SQL" ]; then fi # check if connected to the internet and if server is up -connected=$(/sbin/ping -t 5 -c 1 -on www.dpriver.com 2> /dev/null | grep 'icmp' | wc -l) +connected=$(/sbin/ping -t 8 -c 1 -on www.dpriver.com 2> /dev/null | grep '69\.5\.11\.169' | wc -l) if [ $connected -eq "0" ]; then echo "<font color=red>You are probably not connected to the internet or http://www.dpriver.com/ server is down.</font>" exit $SP_BUNDLE_EXIT_SHOW_AS_HTML_TOOLTIP -- cgit v1.2.3