Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 24 Apr 2014, 21:17
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Web Programming
Post new topic   Reply to topic View previous topic :: View next topic
Page 5 of 5 [63 Posts]   Goto page: Previous 1, 2, 3, 4, 5
Author Message
Ted Dog

Joined: 13 Sep 2005
Posts: 2062
Location: Heart of Texas

PostPosted: Sat 04 Jan 2014, 10:02    Post subject:  

marketing departments minor tax and shipping changes caused a total rewrite of business logic and shopping cart module.. Shocked That they just appended it to an otherwise tiny by programing standards combo ( ALREADY HAD COMBO LOGIC ) combos are just another item code and picture of three items and new price.
Back to top
View user's profile Send private message 

Joined: 18 May 2008
Posts: 4134

PostPosted: Mon 20 Jan 2014, 22:12    Post subject:  

I found free versions of windows images from microsoft for testing with IE

but the images are self extracting .exe so still need windows to create the image.
and probably this helper:

Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 

Joined: 11 Apr 2007
Posts: 878

PostPosted: Sun 09 Feb 2014, 20:48    Post subject: Form_db
Subject description: Create and query html form json database

When technosaurus posted his nifty note-taking html server/client app, I found myself using it quite a bit. Recently it occurred to me that this idea could be expanded to include databases.....

A database seems somewhat complicated - decide on a schema, enter the structure, make up a form for data entry, set up a query operation.

Why not just make up an html form which actually creates and could also query a database?

So here is a simple prototype called "form_db".

Decide on your fields, grab some form html coding (lots of easy on-line form builders and templates available) and just paste the code into Form_db. Now you can just fill in the form and a json database is created and additional entries can be made. To query the database you could have several predefined buttons (each with a "case" statement) to return information based on fields. You could even make a text area to accept a complex query with JQ.

At first I thought I'd have to use Python or maybe Javascript to parse url and read/write json files. But then again, maybe all that could be done in bash and it turns out that it could (although probably lots easier in Python). Now that a Json database has been created, how might it be queried and used in this environment? I then discovered JQ, described as an awk/sed for json here-

Next, how to show the json query return in the open html page?

Handily, there is a javascript widget to display json data. Good, everything we need.

Here's a simple contact form example with a single query button that returns all the contact names.

JQ has extensive ways to return information, including math expressions.

You'll find two scripts which go in $HOME/cgi-bin:
query_string # parses the url and directs action
form_db.cgi # browser form

Also attached is jq below which I compiled in Puppy Precise 5.4.3 and stripped - weighs in at only 247k

To set this up, do the following in a terminal:
mkdir $HOME/cgi-bin
cd $HOME

Install "jq.tar.gz" to /

Place the scripts "query_string" and "form_db.cgi" in $HOME/cgi-bin and make executable.

Then point your browser at url "localhost/cgi-bin/form_db.cgi"

Here's a pic (of course, you could add css styling to make this as decorative as you'd like)


# place script in $HOME/cgi-bin/form_db.cgi
# called by browser "localhost/cgi-bin/form_db.cgi"
# seaside 2/9/2014
# form html code follows:

echo '
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<h2> Contacts </h2>
<form id="contacts-form" action="/cgi-bin/form_db.cgi">
<body bgcolor="#E6E6FA">
<label>First name:</label>
<div class="field"><input type="text" name="first_name" autofocus /></div>
<label>Last name:</label>
<div class="field"><input type="text" name="last_name" /></div>
<div class="field"><input type="text" name="email" /></div>
<input type="radio" name="gender" value="Male" checked> Male
<input type="radio" name="gender" value="Female"> Female
<div class="item button button-default"><br>
<div class="field"><input type="submit" id="contacts-op-save" value="Save" /></div>
<input type="submit" name="id_entry" value="Query All" />

if [ "${QUERY_STRING/id_entry=Query}" = "${QUERY_STRING}" ] ; then
   ./query_string   #  submit item
else    # it's a query

input=`cat /root/cgi-bin/contact.json | jq -c '.'`
echo '<!DOCTYPE html>
<script src="http://metawidget.org/js/3.4/metawidget-core.min.js"></script>
<script type="text/javascript">
var body = '$input'
<div id="metawidget"></div>
<script type="text/javascript">
var mw = new metawidget.Metawidget( document.getElementById( "'metawidget'" ));
mw.toInspect = body;


# place script in $HOME/cgi-bin/query_string
# parses QUERY_STRING from form_db.cgi
# seaside 2/9/2014

[ -z "$QUERY_STRING" ] && exit

QUERY_STRING=$(echo -e $(sed -e 's/%/\\x/g' -e 's/+/ /g' <<<"$QUERY_STRING"))

if [ ! -f $HOME/cgi-bin/contact.json ]; then
   for item in $QUERY_STRING; do
   jstring="$jstring $key:$value,";
   jstring="${jstring%,}}]"  # cut comma, add }]
   echo "$jstring" >$HOME/cgi-bin/contact.json

else    # additional object

   json=`cat $HOME/cgi-bin/contact.json`
   json="${json%]},"    # cut ] add comma
   for item in $QUERY_STRING; do
   json_add="$json_add $key:$value,";
   echo "$json$json_add" >$HOME/cgi-bin/contact.json

 Filesize   15.95 KB
 Viewed   99 Time(s)


Description  jq (json query) compiled and stripped

Filename  jq.tar.gz 
Filesize  94.74 KB 
Downloaded  30 Time(s) 
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 5 of 5 [63 Posts]   Goto page: Previous 1, 2, 3, 4, 5
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0689s ][ Queries: 12 (0.0125s) ][ GZIP on ]