Skip to content

Commit 95fe97f

Browse files
committed
Change Build to Compile
1 parent bd90371 commit 95fe97f

File tree

4 files changed

+201
-44
lines changed

4 files changed

+201
-44
lines changed

README.md

Lines changed: 80 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This plugin for the Web application [Adminer](https://www.adminer.org/en/) allow
66
77
:medal_sports: This plugin is now in the official list of [User Contributed Plugins for Adminer](https://www.adminer.org/en/plugins/#user).
88

9-
## :construction_worker: Install or :gear: Build or :new: :robot: Use :new:
9+
## :construction_worker: Install or :new: :gear: Compile or :robot: Use
1010
### :construction_worker: Install the plugin
1111
The plugin is used like any other [Adminer plugins](https://www.adminer.org/en/plugins/), that is to say that it requires the following files:
1212

@@ -38,36 +38,94 @@ function adminer_object() {
3838
require "./adminer-current.php";
3939
```
4040

41-
### :gear: Build single file version of adminer-4-sqlite3
41+
### :new: :gear: Compile a single file version
4242
This script is used to build a SQLite3 "dedicated" Adminer file:
4343
* easy installation (a file to copy)
44+
* light size (< 190Ko)
45+
* can embedded your favorite design
4446
* respect the philosophy of Adminer
4547
> Adminer consist of a single file ready to deploy to the target server.
4648
```bash
47-
#!/usr/bin/env bash
48-
49-
# define the URLs
50-
ADMINER=https://www.adminer.org/latest.php
51-
PLUGIN=https://raw.github.com/vrana/adminer/master/plugins/plugin.php
52-
MYPLUGIN=https://github.com/FrancoisCapon/LoginToASqlite3DatabaseWithoutCredentialsWithAdminer/raw/master/fc-sqlite-connection-without-credentials.php
53-
# load and concatenate into one file
54-
wget -O adminer-4-sqlite3.php $ADMINER $PLUGIN $MYPLUGIN
55-
56-
# add myplugin to Adminer
57-
# http://tldp.org/LDP/abs/html/here-docs.html#EX71C
58-
cat << "EOPHP" >> adminer-4-sqlite3.php
59-
49+
if [ $# -lt 1 ]
50+
then
51+
echo 'usage: ./compile.sh languagecode [design]'
52+
exit 1
53+
fi
54+
55+
LANGUAGES_DIR="adminer/adminer/lang"
56+
TRANSLATIONS_FILE="warning-translations.csv"
57+
CSS_FILE="adminer/adminer/static/default.css"
58+
DESIGNS_DIR="adminer/designs"
59+
COMPILE_CMD="php adminer/compile.php sqlite "
60+
61+
step=1
62+
if [ ! -d "adminer" ]
63+
then
64+
echo -e "\n$step. Load adminer's sources:\n"
65+
((step+=1))
66+
67+
git clone --recurse-submodules https://github.com/vrana/adminer.git
68+
echo -e "\n$step. Load plugin's sources:\n"
69+
((step+=1))
70+
wget -P adminer/plugins/ https://raw.githubusercontent.com/FrancoisCapon/LoginToASqlite3DatabaseWithoutCredentialsWithAdminer/master/fc-sqlite-connection-without-credentials.php
71+
echo -e "\n$step. Adding the plugin to the sources\n"
72+
((step+=1))
73+
cat << "EOPHP" >> adminer/adminer/include/bootstrap.inc.php
74+
include "../plugins/plugin.php";
75+
include "../plugins/fc-sqlite-connection-without-credentials.php";
6076
function adminer_object() {
61-
$plugins = array(new FCSqliteConnectionWithoutCredentials());
62-
return new AdminerPlugin($plugins);
63-
}
77+
$plugins = array(new FCSqliteConnectionWithoutCredentials());
78+
return new AdminerPlugin($plugins);
79+
}
6480
EOPHP
65-
# remove all the <?php except the first
66-
# http://www.theunixschool.com/2011/02/sed-replace-or-substitute-file-contents.html
67-
sed -i '2,$s/<?php$//' adminer-4-sqlite3.php
81+
fi
82+
83+
echo -e "\n$step. Search warning translation\n"
84+
((step+=1))
85+
86+
language=$1
87+
translation=$(grep ^$language, $TRANSLATIONS_FILE | cut -d',' -f2 | tr -d '\n')
88+
if [ "$translation" != "" ]
89+
then
90+
echo $translation
91+
cp $LANGUAGES_DIR/$language.inc.php $LANGUAGES_DIR/$language.inc.php.backup
92+
sed -i 's/);//' $LANGUAGES_DIR/$language.inc.php
93+
cat << EOPHP >> $LANGUAGES_DIR/$language.inc.php
94+
'Warning: don\'t use it in a production environment!' => '$translation',
95+
);
96+
EOPHP
97+
fi
98+
99+
if [ $# -eq 2 ]
100+
then
101+
design=$2
102+
echo -e "\n$step. Set the design: $design\n"
103+
((step+=1))
104+
cp $CSS_FILE $CSS_FILE.backup
105+
cat $CSS_FILE.backup $DESIGNS_DIR/$design/adminer.css > $CSS_FILE
106+
fi
107+
108+
echo -e "\n$step. Compile in language: $language\n"
109+
((step+=1))
110+
111+
$COMPILE_CMD $language 2> /dev/null
112+
113+
echo -e "\n$step. Clean the sources\n"
114+
((step+=1))
115+
if [ "$translation" != "" ]
116+
then
117+
cp $LANGUAGES_DIR/$language.inc.php.backup $LANGUAGES_DIR/$language.inc.php
118+
fi
119+
120+
if [ $# -eq 2 ]
121+
then
122+
cp $CSS_FILE.backup $CSS_FILE
123+
fi
124+
125+
echo -e "\n$step. Voilà!\n"
68126
```
69127

70-
### :new: :robot: Use the [latest prebuilded release](https://github.com/FrancoisCapon/LoginToASqlite3DatabaseWithoutCredentialsWithAdminer/releases/latest) :new:
128+
### :robot: Use the [latest prebuilded release](https://github.com/FrancoisCapon/LoginToASqlite3DatabaseWithoutCredentialsWithAdminer/releases/latest)
71129

72130
## :desktop_computer: Using Adminer with SQLite3 databases
73131
Simply "authenticate" by clicking on the Authentication button by indicating (or not) the path of an existing database.

build-adminer-4-sqlite3-into-one-file.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

compile.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
if [ $# -lt 1 ]
2+
then
3+
echo 'usage: ./compile.sh languagecode [design]'
4+
exit 1
5+
fi
6+
7+
LANGUAGES_DIR="adminer/adminer/lang"
8+
TRANSLATIONS_FILE="warning-translations.csv"
9+
CSS_FILE="adminer/adminer/static/default.css"
10+
DESIGNS_DIR="adminer/designs"
11+
COMPILE_CMD="php adminer/compile.php sqlite "
12+
13+
step=1
14+
if [ ! -d "adminer" ]
15+
then
16+
echo -e "\n$step. Load adminer's sources:\n"
17+
((step+=1))
18+
19+
git clone --recurse-submodules https://github.com/vrana/adminer.git
20+
echo -e "\n$step. Load plugin's sources:\n"
21+
((step+=1))
22+
wget -P adminer/plugins/ https://raw.githubusercontent.com/FrancoisCapon/LoginToASqlite3DatabaseWithoutCredentialsWithAdminer/master/fc-sqlite-connection-without-credentials.php
23+
echo -e "\n$step. Adding the plugin to the sources\n"
24+
((step+=1))
25+
cat << "EOPHP" >> adminer/adminer/include/bootstrap.inc.php
26+
include "../plugins/plugin.php";
27+
include "../plugins/fc-sqlite-connection-without-credentials.php";
28+
function adminer_object() {
29+
$plugins = array(new FCSqliteConnectionWithoutCredentials());
30+
return new AdminerPlugin($plugins);
31+
}
32+
EOPHP
33+
fi
34+
35+
echo -e "\n$step. Search warning translation\n"
36+
((step+=1))
37+
38+
# TODO echo '<div class="error">'.lang('Warning: don\'t use it in a production environment!').'</div>';
39+
40+
language=$1
41+
translation=$(grep ^$language, $TRANSLATIONS_FILE | cut -d',' -f2 | tr -d '\n')
42+
if [ "$translation" != "" ]
43+
then
44+
echo $translation
45+
cp $LANGUAGES_DIR/$language.inc.php $LANGUAGES_DIR/$language.inc.php.backup
46+
sed -i 's/);//' $LANGUAGES_DIR/$language.inc.php
47+
cat << EOPHP >> $LANGUAGES_DIR/$language.inc.php
48+
'Warning: don\'t use it in a production environment!' => '$translation',
49+
);
50+
EOPHP
51+
fi
52+
53+
if [ $# -eq 2 ]
54+
then
55+
design=$2
56+
echo -e "\n$step. Set the design: $design\n"
57+
((step+=1))
58+
cp $CSS_FILE $CSS_FILE.backup
59+
cat $CSS_FILE.backup $DESIGNS_DIR/$design/adminer.css > $CSS_FILE
60+
fi
61+
62+
echo -e "\n$step. Compile in language: $language\n"
63+
((step+=1))
64+
65+
$COMPILE_CMD $language 2> /dev/null
66+
67+
echo -e "\n$step. Clean the sources\n"
68+
((step+=1))
69+
if [ "$translation" != "" ]
70+
then
71+
cp $LANGUAGES_DIR/$language.inc.php.backup $LANGUAGES_DIR/$language.inc.php
72+
fi
73+
74+
if [ $# -eq 2 ]
75+
then
76+
cp $CSS_FILE.backup $CSS_FILE
77+
fi
78+
79+
echo -e "\n$step. Voilà!\n"

warning-translations.csv

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
ar,
2+
bg,
3+
bn,
4+
bs,
5+
ca,
6+
cs,
7+
da,
8+
de,Warnung: Verwenden Sie es nicht in einer Produktionsumgebung!
9+
el,
10+
es,
11+
et,
12+
fa,
13+
fi,
14+
fr,Attention : ne l\'utilisez pas dans un environnement de production !
15+
gl,
16+
he,
17+
hu,
18+
id,
19+
it,
20+
ja,
21+
ka,
22+
ko,
23+
lt,
24+
ms,
25+
nl,
26+
no,
27+
pl,
28+
pt-br,
29+
pt,
30+
ro,
31+
ru,
32+
sk,
33+
sl,
34+
sr,
35+
sv,
36+
ta,
37+
th,
38+
tr,
39+
uk,
40+
vi,
41+
zh,
42+
zh-tw,

0 commit comments

Comments
 (0)