Custom App
This page guides you through creating custom apps, editing code, and modifying the main page quickly. The below table outlines the four available auth types of Custom Apps.
| Auth Type | Detail | Function | Data source | Code | Data Access |
|---|---|---|---|---|---|
| 1. Shared Pass | Shared Pass Code | auth-form,main-page,table,form,log | specific databox | editable | Controllable per group |
| 2. User Key | Use unique Base64-encoded keys for each user | auth-form,main-page,table,form,log | specific databox | editable | Controllable per user |
| 3. Other | Any | auth-form,main-page,table,form,log | specific databox | editable | Customize everything |
| 4. No auth | No Authentication | main-page,table,show-record(ro) | specific databox | editable | Read only, it can be used as static site |
Required: Please setup Base App beforehand refering to Quick Start.
Common Setup Steps
Each type of custom app has a common set of steps, the main difference lies in the authentication method.
- Generate Databox for datastore
- Generate Custom App
- Update main page with Markdown or HTML tag
- Add user
- Update bin/scripts #optional
- Add subApp #optional
Generate Databox
Please generate databox that will be used for custom app first. For more details of datastore, please see the Data shell documentation.
sudo /usr/local/small-shell/adm/gen -databox
# -> dialog will be started
Generate App
Once databox is ready let's generate custom app. In this example app name is "test" and it will use user key for authentication.
sudo /usr/local/small-shell/adm/gen -app
Type of App (1.BASE | 2.FORM | 3.CUSTOM): 3
App Name: test
Type of Authentication (1.shared pass | 2.user key | 3.other | 4.none): 2
Primary databox: item.db
Auto-generated Management Databoxes
The following databoxes are automatically generated for management purposes when you create a custom app.
- images.db : Used for uploading image files.
- {your_app_name}.UI.md.def : Used for updating the main page definition.
- {your_app_name}.events : Used for registering calendar events of your app.
Update main page
You can update your application's main page on Base App or edit the code directly. Please see cookbook for details. Here is an image of the default main page.

Add user to the App
If you select Key App, please add user for the App. Then you can get URL that can generate key for the end user.
sudo /usr/local/small-shell/adm/ops app:$your_app_name add.usr:$user_name
This exmple is add "test_user" user for App name "test"
sudo /usr/local/small-shell/adm/ops app:test add.usr:test_user
https://${your_server_FQDN}/cgi-bin/auth.test?initialize=cd5e7330e5fb92b4999f2a7801da7267c802c4109a7126be47d5049cd7d5c440,6bc0917d9510ae794ab5cb5d1e65834c09ad11fbd3d78db881a656c591d1604a
Connect to the App
End user key that's generated above command will be stored to end user browser automatically using localstorage by javascript once connected to above url.
Access URL of the App
If you are using default Web server, your application URL must be ${your_server_FQDN}/${your_app_name} except "other" type App. URL will be shown in the dialog of gen command.
e.g.) App:test, URL:https://${your_server_FQDN}/test

Re-generate User key
If end user lost their key, you can generate URL for re-generating key.
sudo /usr/local/small-shell/adm/ops initialize.usr:test app:test
Update Pass code
If it's Shared Pass code App, you can update pass code by updating file directly
sudo vi /usr/local/small-shell/web/${your_app_name}.code
Update codes (optional)
You can update the code freely based on MVC model.
Parameter change of bin/scripts
In this example, accesible key of databox is changed. In the default permission, end user can access all keys of databox from the custom app.
e.g) restrict data keys
sudo vi /var/www/bin/test_get.sh
--code--
# Target databox and keys
#keys=all
keys=item_name,description
--------
Tagging on Custom App
You can add search tag to the table by ops command
sudo /usr/local/small-shell/adm/ops add.tag:$databox{key{word}} app:$your_app_name
e.g.)
sudo /usr/local/small-shell/adm/ops add.tag:tasks{status{on-going}} app:tasks

Change user permission
User permission can be changed by ops command.
# change to read only
sudo /usr/local/small-shell/adm/ops set.attr:$user_name{ro} app:$your_app_name
# change to read / write
sudo /usr/local/small-shell/adm/ops set.attr:$user_name{rw} app:$your_app_name
Add databox to the app
Basically custom app connect to only 1 databox. "Sub App" is the way to add databox to your custom app additionally. Here is an example to add databox "inventory.db" to custom app "test".
sudo /usr/local/small-shell/adm/gen -app
Type of App (1.BASE | 2.FORM | 3.CUSTOM): 3
App Name: inventory@test
Subapp databox: inventory.db
Once sub app deployed, please check routing and menu that will be updaated automatically. You can freely modify them.
# routing
# sudo cat /var/www/cgi-bin/${parent_app}
sudo cat /var/www/cgi-bin/test
# menu
# cat /var/www/def/common_parts/${parent_app_common_menu}
cat /var/www/def/common_parts/test_common_menu
Delete Custom App
You can delete your custom App by using util script as following.
usage: sudo /usr/local/small-shell/util/scripts/del_app.sh $app
Technical Tips
There are technical Tips. please check them.
1. Get ID & key's value
You can get text name using ID and key using "none" format
@bin/script (shell)
# get name which will be issued
DATA_SHELL="sudo -u small-shell ${small_shell_path}/bin/DATA_shell session:$session pin:$pin"
book_name=$($DATA_SHELL databox:book.master action:get key:name id:$id format:none | $AWK -F ":" '{print $2}')
2. ID search by using Name
You can also get ID using 100% matched text
@bin/script (shell)
# get book ID Based on the name
DATA_SHELL="sudo -u small-shell ${small_shell_path}/bin/DATA_shell session:$session pin:$pin"
book_id=$($DATA_SHELL databox:book.master command:show_all[match=name{$book_name}] format:json | jq '.[] | .id'| $SED -s "s/\"//g")
3. Json insert to javascript instance
In terms of integration with javascript frameworks, we would like to recommend to insert bulk of json datas to javascript directly using %% tag because ajax with small-shell will take 1 or 2 sec for getting data.
Json technique (javascript in html def)
events: [
// %%events
],
generator in bin/${app}_main.sh
# app parameter will be your app name
sudo vi /var/www/bin/${app}_main.sh
--code--
# -----------------
# generate json
# -----------------
$DATA_SHELL databox:${app}.events command:show_all format:json \
| $SED "s/{%%%%%%%%%%%%%%%%%}/'/g"\
| $SED "s/{%%%%%%%%%%%%%%%%}/%/g"\
| $SED "s/{%%%%%%%%%%%%%%%}/*/g"\
| $SED "s/{%%%%%%%%%%%%%%}/$/g"\
| $SED "s/{%%%%%%%%%%%%%}/\#/g"\
| $SED "s/{%%%%%%%%%%%%}/|/g"\
| $SED "s/{%%%%%%%%%%%}/\]/g"\
| $SED "s/{%%%%%%%%%%}/\[/g"\
| $SED "s/{%%%%%%%%%}/)/g"\
| $SED "s/{%%%%%%%%}/(/g"\
| $SED "s/{%%%%%%%}/_/g"\
| $SED "s/{%%%%%%}/,/g"\
| $SED "s/{%%%%%}/\//g"\
| $SED "s/{%%%%}/\&/g"\
| $SED "s/{%%%}/:/g" > /var/www/tmp/${session}/events
# -----------------
# render HTML
# -----------------
cat /var/www/def/gentest_main.html.def | $SED -r "s/^( *)</</1" \
| $SED "/%%common_menu/r /var/www/def/common_parts/gentest_common_menu" \
| $SED "s/%%common_menu//g"\
| $SED "/%%events/r /var/www/tmp/${session}/events" \
| $SED "/%%event_add_btn/r /var/www/tmp/${session}/event_add_btn" \
| $SED "s/%%event_add_btn//g"\
| $SED "s/%%user/${user_name}/g" \
| $SED "s/%%session/session=${session}\&pin=${pin}/g" \
| $SED "s/%%params/session=${session}\&pin=${pin}/g"
--------
4. Disable main page
If your App will not use main page, please change main request to table by adding these codes.
sudo vi /var/www/cgi-bin/${app}
--code--
if [ "$req" = "main" ];then
req=table
fi
--------
Import App from template
Creating App template is sub project of small-shell. You can import App template from GitHub.
Team App
This App template could manage not only Team events, but also tasks, shared drive, bookmarks and inquiries.
Team App funcions
| Function | type | Description |
|---|---|---|
| Calendar | main | Manage team events in main page |
| Announcements | sub-app | Share announcement to the team |
| Tasks | sub-app | Manage team tasks {assignment,status,deadline,sync_calendar} |
| Inquiries | sub-app | Manage inquiryes from external users |
| Drive | sub-app | Provide storage that have optional link to share file to external users |
| Bookmarks | sub-app | Manage bookmarks |
| Inquiry | form | Inquiry Form to the Team |
Link to code is here
cd /var/tmp
git clone https://github.com/naruoken/small-shell-apps
cd small-shell-apps/team_app
# Deploy Team App
sudo ./deploy.sh
Add user to Team App
Please add user to the App, then you can get key to access team main.
sudo /usr/local/small-shell/adm/ops app:team add.usr:test

Access URL of Team App
There is 2 URL for using Team App, 1 is for App user, 1 is external user for inquiry. please try to use.
# Team App
https://${FQDN}/team
# Inquiry Form
https://${FQDN}/inquiry