Commit b50929bbd0bac925e7df43ed067f234fdbf9b5d6
1 parent
cfcf018e
add _CXM_MAILING_CHECK_CONTACT in message constant
move db_get_xxx helpers into db_get_helpers.anubis add add_DB_id and find_DB_id functions to able to add and find DB_id in Muscle Message web controller web argument has 2 names versions. The legacy "aws_controller" and the short version"aws_c" web action web argment has 2 names versions. The legacy "aws_action" and the short version "aws_a" add detect_browser_language in /web/CXM_common.anubis
Showing
12 changed files
with
338 additions
and
194 deletions
Show diff stats
CXM_message_constants.anubis
| @@ -123,6 +123,7 @@ public define Word32 _CXM_MAILING_SERVICE_ID = 0x33772200. // s | @@ -123,6 +123,7 @@ public define Word32 _CXM_MAILING_SERVICE_ID = 0x33772200. // s | ||
| 123 | public define Word32 _CXM_MAILING_CREATE_CONTACT = 0x33772201. | 123 | public define Word32 _CXM_MAILING_CREATE_CONTACT = 0x33772201. |
| 124 | public define Word32 _CXM_MAILING_UPDATE_CONTACT = 0x33772202. | 124 | public define Word32 _CXM_MAILING_UPDATE_CONTACT = 0x33772202. |
| 125 | public define Word32 _CXM_MAILING_DELETE_CONTACT = 0x33772203. | 125 | public define Word32 _CXM_MAILING_DELETE_CONTACT = 0x33772203. |
| 126 | +public define Word32 _CXM_MAILING_CHECK_CONTACT = 0x33772204. | ||
| 126 | 127 | ||
| 127 | public define Word32 _CXM_MAILING_CREATE_MAILING = 0x33772211. | 128 | public define Word32 _CXM_MAILING_CREATE_MAILING = 0x33772211. |
| 128 | public define Word32 _CXM_MAILING_UPDATE_MAILING = 0x33772212. | 129 | public define Word32 _CXM_MAILING_UPDATE_MAILING = 0x33772212. |
| 1 | +/* | ||
| 2 | + * Created by PyramIDE. | ||
| 3 | + * User: フランスのトトロ aka (David RENÉ) | ||
| 4 | + * Date: 15/12/2019 | ||
| 5 | + * Time: 13:32 | ||
| 6 | + * © David RENÉ | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +read tools/basis.anubis | ||
| 10 | +read system/logger.anubis | ||
| 11 | +read calexium_lib/net_services_protocols/logger_client.anubis | ||
| 12 | +read system/string.anubis | ||
| 13 | +read data_base/db_tools.anubis | ||
| 14 | +read data_base/sqlite.anubis | ||
| 15 | + | ||
| 16 | +transmit calexium_lib/database/db_types.anubis | ||
| 17 | + | ||
| 18 | +// -- Extractors HELPERS --------------- | ||
| 19 | + | ||
| 20 | + | ||
| 21 | +// sqlite3 API | ||
| 22 | +public define String | ||
| 23 | + db_get_String | ||
| 24 | + ( | ||
| 25 | + One -> SQLite3Row table_cursor | ||
| 26 | + ) = | ||
| 27 | + if table_cursor(unique) is | ||
| 28 | + { | ||
| 29 | + error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_String")); "", | ||
| 30 | + no_more_row then "", //can't find the symbol in the table, because the row is empty | ||
| 31 | + row(explorer) then text(explorer)(0) | ||
| 32 | + } | ||
| 33 | +. | ||
| 34 | + | ||
| 35 | +public define List(String) | ||
| 36 | + db_get_List_String | ||
| 37 | + ( | ||
| 38 | + One -> DbRow table_cursor, | ||
| 39 | + List(String) so_far | ||
| 40 | + ) = | ||
| 41 | + if table_cursor(unique) is | ||
| 42 | + { | ||
| 43 | + error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_string_list")); reverse(so_far), | ||
| 44 | + no_more_row then reverse(so_far), //can't find the symbol in the table, because the row is empty | ||
| 45 | + row(explorer) then | ||
| 46 | + with s = text(explorer)(0), | ||
| 47 | + db_get_List_String(table_cursor, [s . so_far]) | ||
| 48 | + }. | ||
| 49 | + | ||
| 50 | +// sqlite3 API | ||
| 51 | +public define List(String) | ||
| 52 | + db_get_List_String | ||
| 53 | + ( | ||
| 54 | + One -> SQLite3Row table_cursor, | ||
| 55 | + List(String) so_far | ||
| 56 | + ) = | ||
| 57 | + if table_cursor(unique) is | ||
| 58 | + { | ||
| 59 | + error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_string_list")); reverse(so_far), | ||
| 60 | + no_more_row then reverse(so_far), //can't find the symbol in the table, because the row is empty | ||
| 61 | + row(explorer) then | ||
| 62 | + with s = text(explorer)(0), | ||
| 63 | + db_get_List_String(table_cursor, [s . so_far]) | ||
| 64 | + }. | ||
| 65 | + | ||
| 66 | +// sqlite3 API | ||
| 67 | +public define List(String) | ||
| 68 | + db_get_List_String | ||
| 69 | + ( | ||
| 70 | + One -> SQLite3Row table_cursor | ||
| 71 | + ) = | ||
| 72 | + if table_cursor(unique) is | ||
| 73 | + { | ||
| 74 | + error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_string_list")); [], | ||
| 75 | + no_more_row then [], //can't find the symbol in the table, because the row is empty | ||
| 76 | + row(explorer) then | ||
| 77 | + with s = text(explorer)(0), | ||
| 78 | + [ s . db_get_List_String(table_cursor)] | ||
| 79 | + }. | ||
| 80 | + | ||
| 81 | +public define Bool | ||
| 82 | + db_get_Bool | ||
| 83 | + ( | ||
| 84 | + One -> SQLite3Row table_cursor | ||
| 85 | + ) = | ||
| 86 | + if table_cursor(unique) is | ||
| 87 | + { | ||
| 88 | + error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_Bool")); false, | ||
| 89 | + no_more_row then false, //can't find the symbol in the table, because the row is empty | ||
| 90 | + row(explorer) then db_bool(explorer)(0) | ||
| 91 | + } | ||
| 92 | +. | ||
| 93 | + | ||
| 94 | +// sqlite3 API | ||
| 95 | +public define Int | ||
| 96 | + db_get_Int | ||
| 97 | + ( | ||
| 98 | + One -> SQLite3Row table_cursor | ||
| 99 | + ) = | ||
| 100 | + if table_cursor(unique) is | ||
| 101 | + { | ||
| 102 | + error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_integer")); 0, | ||
| 103 | + no_more_row then 0, | ||
| 104 | + row(explorer) then (Int)db_integer(explorer)(0) | ||
| 105 | + } | ||
| 106 | +. | ||
| 107 | + | ||
| 108 | +public define Maybe(Int) | ||
| 109 | + db_get_mb_Int | ||
| 110 | + ( | ||
| 111 | + One -> SQLite3Row table_cursor | ||
| 112 | + ) = | ||
| 113 | + if table_cursor(unique) is | ||
| 114 | + { | ||
| 115 | + error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_mb_integer")); failure, | ||
| 116 | + no_more_row then failure, | ||
| 117 | + row(explorer) then db_integer(explorer)(0) | ||
| 118 | + }. | ||
| 119 | + | ||
| 120 | +// sqlite3 API | ||
| 121 | +public define List(Int) | ||
| 122 | + db_get_List_Int | ||
| 123 | + ( | ||
| 124 | + One -> SQLite3Row table_cursor, | ||
| 125 | + List(Int) so_far | ||
| 126 | + ) = | ||
| 127 | + if table_cursor(unique) is | ||
| 128 | + { | ||
| 129 | + error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_integer_list")); reverse(so_far), | ||
| 130 | + no_more_row then reverse(so_far), //can't find the symbol in the table, because the row is empty | ||
| 131 | + row(explorer) then | ||
| 132 | + with s = (Int)db_integer(explorer)(0), | ||
| 133 | + db_get_List_Int(table_cursor, [s . so_far]) | ||
| 134 | + }. | ||
| 135 | + | ||
| 136 | +public define List(Int) | ||
| 137 | + db_get_List_Int | ||
| 138 | + ( | ||
| 139 | + One -> SQLite3Row table_cursor | ||
| 140 | + ) = | ||
| 141 | + db_get_List_Int(table_cursor, []). | ||
| 142 | + | ||
| 143 | +// sqlite3 API | ||
| 144 | +public define Float | ||
| 145 | + db_get_Float | ||
| 146 | + ( | ||
| 147 | + One -> SQLite3Row table_cursor | ||
| 148 | + ) = | ||
| 149 | + if table_cursor(unique) is | ||
| 150 | + { | ||
| 151 | + error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_Float")); 0.0, | ||
| 152 | + no_more_row then 0.0, | ||
| 153 | + row(explorer) then db_float(explorer)(0) | ||
| 154 | + }. | ||
| 155 | + | ||
| 156 | +// sqlite3 API | ||
| 157 | +public define DB_id | ||
| 158 | + db_get_DB_id | ||
| 159 | + ( | ||
| 160 | + One -> SQLite3Row table_cursor | ||
| 161 | + ) = | ||
| 162 | + if table_cursor(unique) is | ||
| 163 | + { | ||
| 164 | + error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_DB_id")); none, | ||
| 165 | + no_more_row then none, | ||
| 166 | + row(explorer) then | ||
| 167 | + with result = (Int)db_integer(explorer)(0), | ||
| 168 | + if result = -1 | result = 0 then none else db_id(result) | ||
| 169 | + } | ||
| 170 | +. | ||
| 171 | + | ||
| 172 | +public define Maybe(DB_id) | ||
| 173 | + db_get_mb_DB_id | ||
| 174 | + ( | ||
| 175 | + One -> SQLite3Row table_cursor | ||
| 176 | + ) = | ||
| 177 | + if table_cursor(unique) is | ||
| 178 | + { | ||
| 179 | + error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_mb_DB_id")); failure, | ||
| 180 | + no_more_row then failure, | ||
| 181 | + row(explorer) then | ||
| 182 | + with result = (Int)db_integer(explorer)(0), | ||
| 183 | + if result = -1 | result = 0 then success(none) else success(db_id(result)) | ||
| 184 | + } | ||
| 185 | +. | ||
| 186 | + | ||
| 187 | + /***********************************/ | ||
| 188 | + | ||
| 189 | +public define List(Int) | ||
| 190 | + db_get_List_Int | ||
| 191 | + ( | ||
| 192 | + One -> DbRow table_cursor, | ||
| 193 | + List(Int) so_far | ||
| 194 | + ) = | ||
| 195 | + if table_cursor(unique) is | ||
| 196 | + { | ||
| 197 | + error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_integer_list")); reverse(so_far), | ||
| 198 | + no_more_row then reverse(so_far), //can't find the symbol in the table, because the row is empty | ||
| 199 | + row(explorer) then | ||
| 200 | + with s = (Int)db_integer(explorer)(0), | ||
| 201 | + db_get_List_Int(table_cursor, [s . so_far]) | ||
| 202 | + }. | ||
| 203 | + | ||
| 204 | +public define List(Int) | ||
| 205 | + db_get_List_Int | ||
| 206 | + ( | ||
| 207 | + One -> DbRow table_cursor, | ||
| 208 | + ) = | ||
| 209 | + db_get_List_Int(table_cursor, []). | ||
| 210 | + | ||
| 211 | + | ||
| 212 | + Help to construct clause and a list of bind according to list of SQLite3_update_field. | ||
| 213 | + This is useful when we want to construct a SQL query with only needs fields. | ||
| 214 | + | ||
| 215 | + |
database/db_types.anubis
| @@ -21,9 +21,32 @@ transmit calexium_lib/web/CXM_json.anubis | @@ -21,9 +21,32 @@ transmit calexium_lib/web/CXM_json.anubis | ||
| 21 | // none, | 21 | // none, |
| 22 | // db_id(Int value). | 22 | // db_id(Int value). |
| 23 | 23 | ||
| 24 | -public type DB_ID: | ||
| 25 | - none, | ||
| 26 | - pk(Int value). | 24 | +//public type DB_ID: |
| 25 | +// none, | ||
| 26 | +// pk(Int value). | ||
| 27 | + | ||
| 28 | +public define Maybe(One) | ||
| 29 | + add_DB_id | ||
| 30 | + ( | ||
| 31 | + Message msg, | ||
| 32 | + String name, | ||
| 33 | + DB_id db_id | ||
| 34 | + )= | ||
| 35 | + add_message(msg, name, to_Message(db_id)) | ||
| 36 | +. | ||
| 37 | + | ||
| 38 | +public define Maybe(DB_id) | ||
| 39 | + find_DB_id | ||
| 40 | + ( | ||
| 41 | + Message msg, | ||
| 42 | + String name, | ||
| 43 | + )= | ||
| 44 | + if find_message(msg, name) is | ||
| 45 | + { | ||
| 46 | + failure then failure, | ||
| 47 | + success(_db_id__msg) then (Maybe(DB_id))from_Message(_db_id__msg) | ||
| 48 | + } | ||
| 49 | +. | ||
| 27 | 50 | ||
| 28 | public define String | 51 | public define String |
| 29 | to_String | 52 | to_String |
| @@ -150,27 +173,27 @@ public define String | @@ -150,27 +173,27 @@ public define String | ||
| 150 | } | 173 | } |
| 151 | . | 174 | . |
| 152 | 175 | ||
| 153 | -public define String | ||
| 154 | - to_String | ||
| 155 | - ( | ||
| 156 | - DB_ID idx | ||
| 157 | - )= | ||
| 158 | - if idx is | ||
| 159 | - { | ||
| 160 | - none then "none", | ||
| 161 | - pk(_idx) then abs_to_decimal(_idx) | ||
| 162 | - }. | ||
| 163 | - | ||
| 164 | -public define Int | ||
| 165 | - to_Int | ||
| 166 | - ( | ||
| 167 | - DB_ID idx | ||
| 168 | - )= | ||
| 169 | - if idx is | ||
| 170 | - { | ||
| 171 | - none then (Int)-1, | ||
| 172 | - pk(_idx) then _idx | ||
| 173 | - }. | 176 | +//public define String |
| 177 | +// to_String | ||
| 178 | +// ( | ||
| 179 | +// DB_ID idx | ||
| 180 | +// )= | ||
| 181 | +// if idx is | ||
| 182 | +// { | ||
| 183 | +// none then "none", | ||
| 184 | +// pk(_idx) then abs_to_decimal(_idx) | ||
| 185 | +// }. | ||
| 186 | +// | ||
| 187 | +//public define Int | ||
| 188 | +// to_Int | ||
| 189 | +// ( | ||
| 190 | +// DB_ID idx | ||
| 191 | +// )= | ||
| 192 | +// if idx is | ||
| 193 | +// { | ||
| 194 | +// none then (Int)-1, | ||
| 195 | +// pk(_idx) then _idx | ||
| 196 | +// }. | ||
| 174 | 197 | ||
| 175 | public define String | 198 | public define String |
| 176 | to_String | 199 | to_String |
database/db_utils.anubis
| @@ -17,7 +17,7 @@ transmit calexium_lib/database/db_types.anubis | @@ -17,7 +17,7 @@ transmit calexium_lib/database/db_types.anubis | ||
| 17 | transmit calexium_lib/database/db_utils.anubis | 17 | transmit calexium_lib/database/db_utils.anubis |
| 18 | transmit calexium_lib/database/db_binds.anubis | 18 | transmit calexium_lib/database/db_binds.anubis |
| 19 | transmit calexium_lib/database/db_update_fields.anubis | 19 | transmit calexium_lib/database/db_update_fields.anubis |
| 20 | - | 20 | +transmit calexium_lib/database/db_get_helpers.anubis |
| 21 | read calexium_lib/net_services_protocols/logger_client.anubis | 21 | read calexium_lib/net_services_protocols/logger_client.anubis |
| 22 | 22 | ||
| 23 | public define Int one_year_seconds = 365 * 86400. // amount of seconds during 1 year | 23 | public define Int one_year_seconds = 365 * 86400. // amount of seconds during 1 year |
| @@ -194,155 +194,6 @@ public define SQLite3Row | @@ -194,155 +194,6 @@ public define SQLite3Row | ||
| 194 | row(data) | 194 | row(data) |
| 195 | }. | 195 | }. |
| 196 | 196 | ||
| 197 | -// -- Extractors HELPERS --------------- | ||
| 198 | - | ||
| 199 | -// sqlite3 API | ||
| 200 | -public define String | ||
| 201 | - db_get_String | ||
| 202 | - ( | ||
| 203 | - One -> SQLite3Row table_cursor | ||
| 204 | - ) = | ||
| 205 | - if table_cursor(unique) is | ||
| 206 | - { | ||
| 207 | - error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_String")); "", | ||
| 208 | - no_more_row then "", //can't find the symbol in the table, because the row is empty | ||
| 209 | - row(explorer) then text(explorer)(0) | ||
| 210 | - }. | ||
| 211 | - | ||
| 212 | -public define List(String) | ||
| 213 | - db_get_string_list | ||
| 214 | - ( | ||
| 215 | - One -> DbRow table_cursor, | ||
| 216 | - List(String) so_far | ||
| 217 | - ) = | ||
| 218 | - if table_cursor(unique) is | ||
| 219 | - { | ||
| 220 | - error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_string_list")); reverse(so_far), | ||
| 221 | - no_more_row then reverse(so_far), //can't find the symbol in the table, because the row is empty | ||
| 222 | - row(explorer) then | ||
| 223 | - with s = text(explorer)(0), | ||
| 224 | - db_get_string_list(table_cursor, [s . so_far]) | ||
| 225 | - }. | ||
| 226 | - | ||
| 227 | -// sqlite3 API | ||
| 228 | -public define List(String) | ||
| 229 | - db_get_string_list | ||
| 230 | - ( | ||
| 231 | - One -> SQLite3Row table_cursor, | ||
| 232 | - List(String) so_far | ||
| 233 | - ) = | ||
| 234 | - if table_cursor(unique) is | ||
| 235 | - { | ||
| 236 | - error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_string_list")); reverse(so_far), | ||
| 237 | - no_more_row then reverse(so_far), //can't find the symbol in the table, because the row is empty | ||
| 238 | - row(explorer) then | ||
| 239 | - with s = text(explorer)(0), | ||
| 240 | - db_get_string_list(table_cursor, [s . so_far]) | ||
| 241 | - }. | ||
| 242 | - | ||
| 243 | -// sqlite3 API | ||
| 244 | -public define List(String) | ||
| 245 | - db_get_string_list | ||
| 246 | - ( | ||
| 247 | - One -> SQLite3Row table_cursor | ||
| 248 | - ) = | ||
| 249 | - if table_cursor(unique) is | ||
| 250 | - { | ||
| 251 | - error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_string_list")); [], | ||
| 252 | - no_more_row then [], //can't find the symbol in the table, because the row is empty | ||
| 253 | - row(explorer) then | ||
| 254 | - with s = text(explorer)(0), | ||
| 255 | - [ s . db_get_string_list(table_cursor)] | ||
| 256 | - }. | ||
| 257 | - | ||
| 258 | -// sqlite3 API | ||
| 259 | -public define Int | ||
| 260 | - db_get_integer | ||
| 261 | - ( | ||
| 262 | - One -> SQLite3Row table_cursor | ||
| 263 | - ) = | ||
| 264 | - if table_cursor(unique) is | ||
| 265 | - { | ||
| 266 | - error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_integer")); 0, | ||
| 267 | - no_more_row then 0, | ||
| 268 | - row(explorer) then (Int)db_integer(explorer)(0) | ||
| 269 | - }. | ||
| 270 | - | ||
| 271 | -public define Maybe(Int) | ||
| 272 | - db_get_mb_integer | ||
| 273 | - ( | ||
| 274 | - One -> SQLite3Row table_cursor | ||
| 275 | - ) = | ||
| 276 | - if table_cursor(unique) is | ||
| 277 | - { | ||
| 278 | - error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_mb_integer")); failure, | ||
| 279 | - no_more_row then failure, | ||
| 280 | - row(explorer) then db_integer(explorer)(0) | ||
| 281 | - }. | ||
| 282 | - | ||
| 283 | -// sqlite3 API | ||
| 284 | -public define List(Int) | ||
| 285 | - db_get_integer_list | ||
| 286 | - ( | ||
| 287 | - One -> SQLite3Row table_cursor, | ||
| 288 | - List(Int) so_far | ||
| 289 | - ) = | ||
| 290 | - if table_cursor(unique) is | ||
| 291 | - { | ||
| 292 | - error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_integer_list")); reverse(so_far), | ||
| 293 | - no_more_row then reverse(so_far), //can't find the symbol in the table, because the row is empty | ||
| 294 | - row(explorer) then | ||
| 295 | - with s = (Int)db_integer(explorer)(0), | ||
| 296 | - db_get_integer_list(table_cursor, [s . so_far]) | ||
| 297 | - }. | ||
| 298 | - | ||
| 299 | -public define List(Int) | ||
| 300 | - db_get_integer_list | ||
| 301 | - ( | ||
| 302 | - One -> SQLite3Row table_cursor | ||
| 303 | - ) = | ||
| 304 | - db_get_integer_list(table_cursor, []). | ||
| 305 | - | ||
| 306 | -// sqlite3 API | ||
| 307 | -public define Float | ||
| 308 | - db_get_Float | ||
| 309 | - ( | ||
| 310 | - One -> SQLite3Row table_cursor | ||
| 311 | - ) = | ||
| 312 | - if table_cursor(unique) is | ||
| 313 | - { | ||
| 314 | - error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_Float")); 0.0, | ||
| 315 | - no_more_row then 0.0, | ||
| 316 | - row(explorer) then db_float(explorer)(0) | ||
| 317 | - }. | ||
| 318 | - | ||
| 319 | -public define List(Int) | ||
| 320 | - db_get_integer_list | ||
| 321 | - ( | ||
| 322 | - One -> DbRow table_cursor, | ||
| 323 | - List(Int) so_far | ||
| 324 | - ) = | ||
| 325 | - if table_cursor(unique) is | ||
| 326 | - { | ||
| 327 | - error(sql_error) then logError("", "DB", db_error(sql_error, "db_get_integer_list")); reverse(so_far), | ||
| 328 | - no_more_row then reverse(so_far), //can't find the symbol in the table, because the row is empty | ||
| 329 | - row(explorer) then | ||
| 330 | - with s = (Int)db_integer(explorer)(0), | ||
| 331 | - db_get_integer_list(table_cursor, [s . so_far]) | ||
| 332 | - }. | ||
| 333 | - | ||
| 334 | -public define List(Int) | ||
| 335 | - db_get_integer_list | ||
| 336 | - ( | ||
| 337 | - One -> DbRow table_cursor, | ||
| 338 | - ) = | ||
| 339 | - db_get_integer_list(table_cursor, []). | ||
| 340 | - | ||
| 341 | - | ||
| 342 | - Help to construct clause and a list of bind according to list of SQLite3_update_field. | ||
| 343 | - This is useful when we want to construct a SQL query with only needs fields. | ||
| 344 | - | ||
| 345 | - | ||
| 346 | 197 | ||
| 347 | 198 | ||
| 348 | 199 |
database/migration_common.anubis
| @@ -143,8 +143,8 @@ public define Maybe(One) | @@ -143,8 +143,8 @@ public define Maybe(One) | ||
| 143 | [h . t] then | 143 | [h . t] then |
| 144 | if sql_query_timeout(db, h, "Version "+version_string+": create indexes") is | 144 | if sql_query_timeout(db, h, "Version "+version_string+": create indexes") is |
| 145 | { | 145 | { |
| 146 | - failure then failure, | ||
| 147 | - success(_) then | 146 | + failure then failure, |
| 147 | + success(_) then | ||
| 148 | create_indexes(db, logger, t, version_string) | 148 | create_indexes(db, logger, t, version_string) |
| 149 | } | 149 | } |
| 150 | }. | 150 | }. |
database/migration_common_sqlite3.anubis
| @@ -12,6 +12,7 @@ read data_base/sqlite.anubis | @@ -12,6 +12,7 @@ read data_base/sqlite.anubis | ||
| 12 | read data_base/alter_table.anubis //for sqlite3 version of alter_table | 12 | read data_base/alter_table.anubis //for sqlite3 version of alter_table |
| 13 | read data_base/db_types.anubis //FK... | 13 | read data_base/db_types.anubis //FK... |
| 14 | read data_base/sqlite_foreign_key.anubis | 14 | read data_base/sqlite_foreign_key.anubis |
| 15 | +read db_get_helpers.anubis | ||
| 15 | 16 | ||
| 16 | read calexium_lib/database/db_utils.anubis | 17 | read calexium_lib/database/db_utils.anubis |
| 17 | //read calexium_lib/net_services_protocols/logger_service.anubis | 18 | //read calexium_lib/net_services_protocols/logger_service.anubis |
| @@ -90,7 +91,7 @@ public define Maybe(One) | @@ -90,7 +91,7 @@ public define Maybe(One) | ||
| 90 | error(err2) then log(logError, db_error(err2, "Failed to drop trigger '" + name + "'")), | 91 | error(err2) then log(logError, db_error(err2, "Failed to drop trigger '" + name + "'")), |
| 91 | ok(_, cursor, _) then unique | 92 | ok(_, cursor, _) then unique |
| 92 | }, | 93 | }, |
| 93 | - map_forget(drop_trigger, db_get_string_list(cursor, [])); | 94 | + map_forget(drop_trigger, db_get_List_String(cursor, [])); |
| 94 | success(unique) | 95 | success(unique) |
| 95 | }. | 96 | }. |
| 96 | 97 |
database/migration_sqlite3.anubis
| @@ -13,6 +13,7 @@ read system/string.anubis | @@ -13,6 +13,7 @@ read system/string.anubis | ||
| 13 | read data_base/sqlite.anubis | 13 | read data_base/sqlite.anubis |
| 14 | read calexium_lib/database/alter_table.anubis | 14 | read calexium_lib/database/alter_table.anubis |
| 15 | read calexium_lib/database/db_utils.anubis | 15 | read calexium_lib/database/db_utils.anubis |
| 16 | +read calexium_lib/database/db_get_helpers.anubis | ||
| 16 | //read calexium_lib/net_services_protocols/logger_client.anubis | 17 | //read calexium_lib/net_services_protocols/logger_client.anubis |
| 17 | read calexium_lib/types/version.anubis | 18 | read calexium_lib/types/version.anubis |
| 18 | 19 |
web/CXM_common.anubis
| @@ -3,8 +3,8 @@ | @@ -3,8 +3,8 @@ | ||
| 3 | *Title* Some common stuff for the web. | 3 | *Title* Some common stuff for the web. |
| 4 | 4 | ||
| 5 | *Copyright* | 5 | *Copyright* |
| 6 | - Copyright (c) Alain Prouté 2003~2007. | ||
| 7 | - © David RENÉ2007~2017 | 6 | + Copyright © Alain Prouté 2003~2007. |
| 7 | + © David RENÉ2007~2019 | ||
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | *Authors:* | 10 | *Authors:* |
| @@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
| 17 | 17 | ||
| 18 | transmit tools/basis.anubis | 18 | transmit tools/basis.anubis |
| 19 | transmit system/string.anubis | 19 | transmit system/string.anubis |
| 20 | - | 20 | +read system/logger.anubis |
| 21 | /** | 21 | /** |
| 22 | * The type 'HTTP_header' describes HTTP headers, which are just pairs '(name,value)'. | 22 | * The type 'HTTP_header' describes HTTP headers, which are just pairs '(name,value)'. |
| 23 | */ | 23 | */ |
| @@ -267,3 +267,31 @@ public define List(String) | @@ -267,3 +267,31 @@ public define List(String) | ||
| 267 | } | 267 | } |
| 268 | . | 268 | . |
| 269 | 269 | ||
| 270 | +public define String | ||
| 271 | + detect_browser_language | ||
| 272 | + ( | ||
| 273 | + HTTP_Info http_info, | ||
| 274 | + String default_language, | ||
| 275 | + (LogLevel, String) -> One logger | ||
| 276 | + ) = | ||
| 277 | + logger(logInfo,"Detecting language... "); | ||
| 278 | + if http_header_value(http_info.http_headers, "Accept-Language") is | ||
| 279 | + { | ||
| 280 | + failure then logger(logDebug, "FAILED: unable to find 'Accept-Language' header, use the default one ["+default_language+"]."); default_language , | ||
| 281 | + success(value) then | ||
| 282 | + if split_by_token(value, ',') is | ||
| 283 | + { | ||
| 284 | + [] then logger(logDebug, "FAILED: language header is empty, use the default one ["+default_language+"]."); default_language, | ||
| 285 | + [h . _] then | ||
| 286 | + //TODO real managment of language and country like fr-be for | ||
| 287 | + // belgium french. | ||
| 288 | + //but now we only extract the language and forget the country | ||
| 289 | + if split_by_token(trim(h), '-') is | ||
| 290 | + { | ||
| 291 | + [] then default_language, | ||
| 292 | + [browser_lang . _] then | ||
| 293 | + logger(logDebug, "Language = " + browser_lang);browser_lang | ||
| 294 | + } | ||
| 295 | + } | ||
| 296 | + } | ||
| 297 | +. |
web/CXM_multihost_http_server.anubis
| @@ -3,9 +3,9 @@ | @@ -3,9 +3,9 @@ | ||
| 3 | 3 | ||
| 4 | *Title* A Multi Host HTTP/HTTPS Server | 4 | *Title* A Multi Host HTTP/HTTPS Server |
| 5 | 5 | ||
| 6 | - *Copyright* Copyright (c) Anubis Team 2003-2007. | ||
| 7 | - (c) Calexium 2007-2013 | ||
| 8 | - (c) David René 2014-2019 | 6 | + *Copyright* Copyright © Anubis Team 2003-2007. |
| 7 | + © Calexium 2007-2013 | ||
| 8 | + © David René 2014-2019 | ||
| 9 | 9 | ||
| 10 | 10 | ||
| 11 | *Authors* Alain Prouté | 11 | *Authors* Alain Prouté |
web/CXM_web_arg_utils.anubis
web/CXM_web_session.anubis
| @@ -1017,18 +1017,23 @@ public define One | @@ -1017,18 +1017,23 @@ public define One | ||
| 1017 | "AWS_CURRENT_PAGE_RENDERER" String current page renderer | 1017 | "AWS_CURRENT_PAGE_RENDERER" String current page renderer |
| 1018 | 1018 | ||
| 1019 | public define One set_web_app(WEB_Session s, String n) = replace_String(s.fields, "AWS_CURRENT_APP", n). | 1019 | public define One set_web_app(WEB_Session s, String n) = replace_String(s.fields, "AWS_CURRENT_APP", n). |
| 1020 | +public define One set_web_app(Var(List(WEB_Session_Field)) fields, String n) = replace_String(fields, "AWS_CURRENT_APP", n). | ||
| 1020 | public define String get_web_app(WEB_Session s) = get_String (s.fields, "AWS_CURRENT_APP", ""). | 1021 | public define String get_web_app(WEB_Session s) = get_String (s.fields, "AWS_CURRENT_APP", ""). |
| 1021 | 1022 | ||
| 1022 | public define One set_web_space(WEB_Session s, String n)= replace_String(s.fields, "AWS_CURRENT_SPACE", n). | 1023 | public define One set_web_space(WEB_Session s, String n)= replace_String(s.fields, "AWS_CURRENT_SPACE", n). |
| 1024 | +public define One set_web_space(Var(List(WEB_Session_Field)) fields, String n)= replace_String(fields, "AWS_CURRENT_SPACE", n). | ||
| 1023 | public define String get_web_space(WEB_Session s) = get_String (s.fields, "AWS_CURRENT_SPACE", ""). | 1025 | public define String get_web_space(WEB_Session s) = get_String (s.fields, "AWS_CURRENT_SPACE", ""). |
| 1024 | 1026 | ||
| 1025 | public define One set_web_content(WEB_Session s, String n)= replace_String(s.fields, "AWS_CURRENT_CONTENT", n). | 1027 | public define One set_web_content(WEB_Session s, String n)= replace_String(s.fields, "AWS_CURRENT_CONTENT", n). |
| 1028 | +public define One set_web_content(Var(List(WEB_Session_Field)) fields, String n)= replace_String(fields, "AWS_CURRENT_CONTENT", n). | ||
| 1026 | public define String get_web_content(WEB_Session s) = get_String (s.fields, "AWS_CURRENT_CONTENT", ""). | 1029 | public define String get_web_content(WEB_Session s) = get_String (s.fields, "AWS_CURRENT_CONTENT", ""). |
| 1027 | 1030 | ||
| 1028 | public define One set_page_title(WEB_Session s, String n)= replace_String(s.fields, "AWS_CURRENT_PAGE_TITLE", n). | 1031 | public define One set_page_title(WEB_Session s, String n)= replace_String(s.fields, "AWS_CURRENT_PAGE_TITLE", n). |
| 1032 | +public define One set_page_title(Var(List(WEB_Session_Field)) fields, String n)= replace_String(fields, "AWS_CURRENT_PAGE_TITLE", n). | ||
| 1029 | public define String get_page_title(WEB_Session s) = get_String (s.fields, "AWS_CURRENT_PAGE_TITLE", ""). | 1033 | public define String get_page_title(WEB_Session s) = get_String (s.fields, "AWS_CURRENT_PAGE_TITLE", ""). |
| 1030 | 1034 | ||
| 1031 | public define One set_renderer(WEB_Session s, String n) = replace_String(s.fields, "AWS_CURRENT_PAGE_RENDERER", n). | 1035 | public define One set_renderer(WEB_Session s, String n) = replace_String(s.fields, "AWS_CURRENT_PAGE_RENDERER", n). |
| 1036 | +public define One set_renderer(Var(List(WEB_Session_Field)) fields, String n) = replace_String(fields, "AWS_CURRENT_PAGE_RENDERER", n). | ||
| 1032 | public define String get_renderer(WEB_Session s) = get_String (s.fields, "AWS_CURRENT_PAGE_RENDERER", ""). | 1037 | public define String get_renderer(WEB_Session s) = get_String (s.fields, "AWS_CURRENT_PAGE_RENDERER", ""). |
| 1033 | 1038 | ||
| 1034 | 1039 |
web/controllers_web_site.anubis
| @@ -24,7 +24,7 @@ read plugin/plugin.anubis | @@ -24,7 +24,7 @@ read plugin/plugin.anubis | ||
| 24 | read CXM_making_a_web_site.anubis | 24 | read CXM_making_a_web_site.anubis |
| 25 | 25 | ||
| 26 | read calexium_lib/web/plugin/plugin.anubis | 26 | read calexium_lib/web/plugin/plugin.anubis |
| 27 | -read config/logger_config.anubis | 27 | + read config/logger_config.anubis |
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | 30 | ||
| @@ -419,7 +419,20 @@ define WEB_Page_Renderer | @@ -419,7 +419,20 @@ define WEB_Page_Renderer | ||
| 419 | 419 | ||
| 420 | public define JsonValue to_html_ajax_content(Printable_tree content_HTML, String additional_script). | 420 | public define JsonValue to_html_ajax_content(Printable_tree content_HTML, String additional_script). |
| 421 | public define JsonValue to_html_ajax_content(HTML_Partial_Content content_HTML, CommonInfo cinfo, String additional_script). | 421 | public define JsonValue to_html_ajax_content(HTML_Partial_Content content_HTML, CommonInfo cinfo, String additional_script). |
| 422 | - | 422 | + |
| 423 | +define String | ||
| 424 | + get_controller_from_web_arg | ||
| 425 | + ( | ||
| 426 | + List(Web_arg) lwa, | ||
| 427 | + String default | ||
| 428 | + )= | ||
| 429 | + if get_String(lwa, "aws_controller") is { failure then | ||
| 430 | + if get_String(lwa, "aws_c") is { failure then default, | ||
| 431 | + success(controller) then controller} | ||
| 432 | + success(controller) then controller | ||
| 433 | + } | ||
| 434 | +. | ||
| 435 | + | ||
| 423 | define (Maybe(WEB_Session), HTTP_Answer) | 436 | define (Maybe(WEB_Session), HTTP_Answer) |
| 424 | apply_controller_action | 437 | apply_controller_action |
| 425 | ( | 438 | ( |
| @@ -438,10 +451,15 @@ define (Maybe(WEB_Session), HTTP_Answer) | @@ -438,10 +451,15 @@ define (Maybe(WEB_Session), HTTP_Answer) | ||
| 438 | )= | 451 | )= |
| 439 | //get the action name | 452 | //get the action name |
| 440 | with mb_action_name = | 453 | with mb_action_name = |
| 441 | - if _mb_action_name is | ||
| 442 | - { | ||
| 443 | - failure then get_String(*_session.web_request.lwa, "aws_action"), | ||
| 444 | - success(_an) then success(_an) | 454 | + if _mb_action_name is |
| 455 | + { | ||
| 456 | + failure then | ||
| 457 | + if get_String(*_session.web_request.lwa, "aws_action") is | ||
| 458 | + { | ||
| 459 | + failure then get_String(*_session.web_request.lwa, "aws_a"), | ||
| 460 | + success(_an) then success(_an) | ||
| 461 | + } | ||
| 462 | + success(_an) then success(_an) | ||
| 445 | }, | 463 | }, |
| 446 | 464 | ||
| 447 | if mb_action_name is | 465 | if mb_action_name is |
| @@ -449,7 +467,7 @@ define (Maybe(WEB_Session), HTTP_Answer) | @@ -449,7 +467,7 @@ define (Maybe(WEB_Session), HTTP_Answer) | ||
| 449 | failure then | 467 | failure then |
| 450 | //(failure, error_page(http_not_found, "Action name failure", _session)), | 468 | //(failure, error_page(http_not_found, "Action name failure", _session)), |
| 451 | with new_session = initial_session(_session.web_request.http_info, _session.web_request.lwa, _session.web_request.is_https), | 469 | with new_session = initial_session(_session.web_request.http_info, _session.web_request.lwa, _session.web_request.is_https), |
| 452 | - if get_controller(get_String(*new_session.web_request.lwa, "aws_controller", "root"), controllers, logger) is | 470 | + if get_controller(get_controller_from_web_arg(*new_session.web_request.lwa, "root"), controllers, logger) is |
| 453 | { | 471 | { |
| 454 | failure then (failure, error_page(http_not_found, "Initial Session Controller not found", new_session)), | 472 | failure then (failure, error_page(http_not_found, "Initial Session Controller not found", new_session)), |
| 455 | success(new_controller) then apply_controller_action(new_controller, plugins, controllers, _current_page_renderer, page_renderers, cinfo, new_session, failure, initial_session, logger), | 473 | success(new_controller) then apply_controller_action(new_controller, plugins, controllers, _current_page_renderer, page_renderers, cinfo, new_session, failure, initial_session, logger), |
| @@ -477,7 +495,7 @@ define (Maybe(WEB_Session), HTTP_Answer) | @@ -477,7 +495,7 @@ define (Maybe(WEB_Session), HTTP_Answer) | ||
| 477 | (success(new_web_session), answer), | 495 | (success(new_web_session), answer), |
| 478 | 496 | ||
| 479 | redirect(new_session) then | 497 | redirect(new_session) then |
| 480 | - if get_controller(get_String(*new_session.web_request.lwa, "aws_controller", "root"), controllers, logger) is | 498 | + if get_controller(get_controller_from_web_arg(*new_session.web_request.lwa, "root"), controllers, logger) is |
| 481 | { | 499 | { |
| 482 | failure then (failure, error_page(http_not_found, "Redirect Controller not found", new_session)), | 500 | failure then (failure, error_page(http_not_found, "Redirect Controller not found", new_session)), |
| 483 | success(new_controller) then apply_controller_action(new_controller, plugins, controllers, _current_page_renderer, page_renderers, cinfo, new_session, failure, initial_session, logger), | 501 | success(new_controller) then apply_controller_action(new_controller, plugins, controllers, _current_page_renderer, page_renderers, cinfo, new_session, failure, initial_session, logger), |
| @@ -492,7 +510,7 @@ define (Maybe(WEB_Session), HTTP_Answer) | @@ -492,7 +510,7 @@ define (Maybe(WEB_Session), HTTP_Answer) | ||
| 492 | }, | 510 | }, |
| 493 | 511 | ||
| 494 | redirect_to_previous then | 512 | redirect_to_previous then |
| 495 | - if get_controller(get_String(*_session.previous_web_request.lwa, "aws_controller", "root"), controllers, logger) is | 513 | + if get_controller(get_controller_from_web_arg(*_session.previous_web_request.lwa, "root"), controllers, logger) is |
| 496 | { | 514 | { |
| 497 | failure then (failure, error_page(http_not_found, "Redirect to previous Controller not found", _session)), | 515 | failure then (failure, error_page(http_not_found, "Redirect to previous Controller not found", _session)), |
| 498 | success(new_controller) then | 516 | success(new_controller) then |
| @@ -500,7 +518,7 @@ define (Maybe(WEB_Session), HTTP_Answer) | @@ -500,7 +518,7 @@ define (Maybe(WEB_Session), HTTP_Answer) | ||
| 500 | apply_controller_action(new_controller, plugins, controllers, _current_page_renderer, page_renderers, cinfo, web_session(id, lang, entries, previous, previous, draw), failure, initial_session, logger), | 518 | apply_controller_action(new_controller, plugins, controllers, _current_page_renderer, page_renderers, cinfo, web_session(id, lang, entries, previous, previous, draw), failure, initial_session, logger), |
| 501 | }, | 519 | }, |
| 502 | redirect_to_previous(entries) then | 520 | redirect_to_previous(entries) then |
| 503 | - if get_controller(get_String(*_session.previous_web_request.lwa, "aws_controller", "root"), controllers, logger) is | 521 | + if get_controller(get_controller_from_web_arg(*_session.previous_web_request.lwa, "root"), controllers, logger) is |
| 504 | { | 522 | { |
| 505 | failure then (failure, error_page(http_not_found, "Redirect to previous Controller not found", _session)), | 523 | failure then (failure, error_page(http_not_found, "Redirect to previous Controller not found", _session)), |
| 506 | success(new_controller) then | 524 | success(new_controller) then |
| @@ -622,7 +640,7 @@ public define Web_Site | @@ -622,7 +640,7 @@ public define Web_Site | ||
| 622 | 640 | ||
| 623 | //apply the action according to current session | 641 | //apply the action according to current session |
| 624 | //since apply_controller_action(get_controller(get_String(lwa, "aws_controller", "root"), *web_controllers), *web_controllers, current_session) | 642 | //since apply_controller_action(get_controller(get_String(lwa, "aws_controller", "root"), *web_controllers), *web_controllers, current_session) |
| 625 | - since if get_controller(get_String(*current_session.web_request.lwa, "aws_controller", "root"), *web_controllers, logger) is | 643 | + since if get_controller(get_controller_from_web_arg(*current_session.web_request.lwa, "root"), *web_controllers, logger) is |
| 626 | { | 644 | { |
| 627 | failure then | 645 | failure then |
| 628 | (failure, error_page(http_not_found, "Controller not found", current_session)), | 646 | (failure, error_page(http_not_found, "Controller not found", current_session)), |