diff --git a/go.mod b/go.mod index 5c66810..285c21f 100644 --- a/go.mod +++ b/go.mod @@ -4,12 +4,13 @@ go 1.22.5 require ( github.com/coreos/go-oidc/v3 v3.11.0 - github.com/fsnotify/fsnotify v1.7.0 github.com/gofiber/contrib/fiberzerolog v1.0.2 github.com/gofiber/fiber/v2 v2.52.5 github.com/gofiber/template/html/v2 v2.1.2 github.com/golang-migrate/migrate/v4 v4.17.1 + github.com/google/uuid v1.6.0 github.com/jackc/pgx/v5 v5.6.0 + github.com/lib/pq v1.10.9 github.com/rs/zerolog v1.33.0 github.com/yuin/goldmark v1.7.4 github.com/yuin/goldmark-meta v1.1.0 @@ -22,7 +23,6 @@ require ( github.com/go-jose/go-jose/v4 v4.0.2 // indirect github.com/gofiber/template v1.8.3 // indirect github.com/gofiber/utils v1.1.0 // indirect - github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa // indirect diff --git a/go.sum b/go.sum index e2ab9d4..599d273 100644 --- a/go.sum +++ b/go.sum @@ -21,8 +21,6 @@ github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKoh github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= -github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/go-jose/go-jose/v4 v4.0.2 h1:R3l3kkBds16bO7ZFAEEcofK0MkrAJt3jlJznWZG0nvk= github.com/go-jose/go-jose/v4 v4.0.2/go.mod h1:WVf9LFMHh/QVrmqrOfqun0C45tMe3RoiKJMPvgWwLfY= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= diff --git a/internal/apps/flags/data/country_codes.json b/internal/apps/flags/data/country_codes.json new file mode 100644 index 0000000..2cbbc99 --- /dev/null +++ b/internal/apps/flags/data/country_codes.json @@ -0,0 +1,252 @@ +[ + {"code": "BD", "tags": ["Asia"]}, + {"code": "BE", "tags": ["Europe", "NatoMembers"]}, + {"code": "BF", "tags": ["Africa", "WestAfrica"]}, + {"code": "BG", "tags": ["Europe", "Balkans"]}, + {"code": "BA", "tags": ["Europe", "Balkans"]}, + {"code": "BB", "tags": ["Caribbean"]}, + {"code": "WF", "tags": ["Caribbean"]}, + {"code": "BL", "tags": []}, + {"code": "BM", "tags": ["NorthAmerica"]}, + {"code": "BN", "tags": ["Asia", "SoutheastAsia"]}, + {"code": "BO", "tags": ["SouthAmerica"]}, + {"code": "BH", "tags": ["MiddleEast", "Asia"]}, + {"code": "BI", "tags": ["Africa", "EastAfrica"]}, + {"code": "BJ", "tags": ["Africa", "WestAfrica"]}, + {"code": "BT", "tags": ["Asia"]}, + {"code": "JM", "tags": ["Caribbean"]}, + {"code": "BV", "tags": []}, + {"code": "BW", "tags": ["Africa", "SouthernAfrica"]}, + {"code": "WS", "tags": ["Oceania"]}, + {"code": "BQ", "tags": []}, + {"code": "BR", "tags": ["South America"]}, + {"code": "BS", "tags": ["Caribbean"]}, + {"code": "JE", "tags": ["Europe"]}, + {"code": "BY", "tags": ["Europe"]}, + {"code": "BZ", "tags": ["CentralAmerica"]}, + {"code": "RU", "tags": ["Europe", "Asia"]}, + {"code": "RW", "tags": ["Africa", "EastAfrica"]}, + {"code": "RS", "tags": ["Europe", "Balkans"]}, + {"code": "TL", "tags": ["Oceania", "SoutheastAsia"]}, + {"code": "RE", "tags": []}, + {"code": "TM", "tags": ["Asia", "CentralAsia"]}, + {"code": "TJ", "tags": ["Asia", "CentralAsia"]}, + {"code": "RO", "tags": ["Europe"]}, + {"code": "TK", "tags": []}, + {"code": "GW", "tags": ["Africa", "WestAfrica"]}, + {"code": "GU", "tags": []}, + {"code": "GT", "tags": ["Central America"]}, + {"code": "GS", "tags": []}, + {"code": "GR", "tags": ["Europe", "Balkans"]}, + {"code": "GQ", "tags": ["Africa", "CentralAfrica"]}, + {"code": "GP", "tags": []}, + {"code": "JP", "tags": ["Asia"]}, + {"code": "GY", "tags": ["SouthAmerica"]}, + {"code": "GG", "tags": ["Europe"]}, + {"code": "GF", "tags": []}, + {"code": "GE", "tags": ["Asia", "MiddleEast"]}, + {"code": "GD", "tags": ["Caribbean"]}, + {"code": "GB", "tags": ["Europe", "NatoMembers"]}, + {"code": "GA", "tags": ["Africa", "CentralAfrica"]}, + {"code": "SV", "tags": ["CentralAmerica"]}, + {"code": "GN", "tags": ["Africa", "WestAfrica"]}, + {"code": "GM", "tags": ["Africa", "WestAfrica"]}, + {"code": "GL", "tags": ["NorthAmerica"]}, + {"code": "GI", "tags": ["Europe"]}, + {"code": "GH", "tags": ["Africa", "WestAfrica"]}, + {"code": "OM", "tags": ["Asia", "MiddleEast"]}, + {"code": "TN", "tags": ["Africa", "NorthAfrica"]}, + {"code": "JO", "tags": ["Asia", "MiddleEast"]}, + {"code": "HR", "tags": ["Europe", "Balkans"]}, + {"code": "HT", "tags": ["Caribbean"]}, + {"code": "HU", "tags": ["Europe"]}, + {"code": "HK", "tags": ["Asia"]}, + {"code": "HN", "tags": ["CentralAmerica"]}, + {"code": "HM", "tags": ["Oceania"]}, + {"code": "VE", "tags": ["SouthAmerica"]}, + {"code": "PR", "tags": []}, + {"code": "PS", "tags": ["Asia", "MiddleEast"]}, + {"code": "PW", "tags": ["Oceania"]}, + {"code": "PT", "tags": ["Europe"]}, + {"code": "SJ", "tags": []}, + {"code": "PY", "tags": ["SouthAmerica"]}, + {"code": "IQ", "tags": ["Asia", "MiddleEast"]}, + {"code": "PA", "tags": ["CentralAmerica"]}, + {"code": "PF", "tags": []}, + {"code": "PG", "tags": ["Oceania"]}, + {"code": "PE", "tags": ["SouthAmerica"]}, + {"code": "PK", "tags": ["Asia"]}, + {"code": "PH", "tags": ["Asia", "SoutheastAsia"]}, + {"code": "PN", "tags": []}, + {"code": "PL", "tags": ["Europe"]}, + {"code": "PM", "tags": []}, + {"code": "ZM", "tags": ["Africa", "EastAfrica"]}, + {"code": "EH", "tags": ["Africa", "WestAfrica", "NorthAfrica"]}, + {"code": "EE", "tags": ["Europe", "NatoMembers"]}, + {"code": "EG", "tags": ["Africa", "NorthAfrica"]}, + {"code": "ZA", "tags": ["Africa", "SouthernAfrica"]}, + {"code": "EC", "tags": ["SouthAmerica"]}, + {"code": "IT", "tags": ["Europe"]}, + {"code": "VN", "tags": ["Asia", "SoutheastAsia"]}, + {"code": "SB", "tags": ["Oceania"]}, + {"code": "ET", "tags": ["Africa", "EastAfrica"]}, + {"code": "SO", "tags": ["Africa", "EastAfrica"]}, + {"code": "ZW", "tags": ["Africa", "EastAfrica"]}, + {"code": "SA", "tags": ["Asia", "MiddleEast"]}, + {"code": "ES", "tags": ["Europe"]}, + {"code": "ER", "tags": ["Africa", "EastAfrica"]}, + {"code": "ME", "tags": ["Europe", "Balkans"]}, + {"code": "MD", "tags": ["Europe"]}, + {"code": "MG", "tags": ["Africa", "EastAfrica"]}, + {"code": "MF", "tags": []}, + {"code": "MA", "tags": ["Africa", "NorthAfrica"]}, + {"code": "MC", "tags": ["Europe"]}, + {"code": "UZ", "tags": ["Asia", "CentralAsia"]}, + {"code": "MM", "tags": ["Asia", "SoutheastAsia"]}, + {"code": "ML", "tags": ["Africa", "WestAfrica"]}, + {"code": "MO", "tags": ["Asia"]}, + {"code": "MN", "tags": ["Asia"]}, + {"code": "MH", "tags": ["Oceania"]}, + {"code": "MK", "tags": ["Europe", "Balkans"]}, + {"code": "MU", "tags": ["Africa", "EastAfrica"]}, + {"code": "MT", "tags": ["Europe"]}, + {"code": "MW", "tags": ["Africa", "EastAfrica"]}, + {"code": "MV", "tags": ["Asia"]}, + {"code": "MQ", "tags": []}, + {"code": "MP", "tags": []}, + {"code": "MS", "tags": ["Caribbean"]}, + {"code": "MR", "tags": ["Africa", "WestAfrica"]}, + {"code": "IM", "tags": ["Europe"]}, + {"code": "UG", "tags": ["Africa", "EastAfrica"]}, + {"code": "TZ", "tags": ["Africa", "EastAfrica"]}, + {"code": "MY", "tags": ["Asia", "SoutheastAsia"]}, + {"code": "MX", "tags": ["NorthAmerica", "CentralAmerica"]}, + {"code": "IL", "tags": ["Asia", "MiddleEast"]}, + {"code": "FR", "tags": ["Europe"]}, + {"code": "IO", "tags": []}, + {"code": "SH", "tags": []}, + {"code": "FI", "tags": ["Europe"]}, + {"code": "FJ", "tags": ["Oceania"]}, + {"code": "FK", "tags": ["SouthAmerica"]}, + {"code": "FM", "tags": ["Oceania"]}, + {"code": "FO", "tags": ["Europe"]}, + {"code": "NI", "tags": ["CentralAmerica"]}, + {"code": "NL", "tags": ["Europe"]}, + {"code": "NO", "tags": ["Europe"]}, + {"code": "NA", "tags": ["Africa", "SouthernAfrica"]}, + {"code": "VU", "tags": ["Oceania"]}, + {"code": "NC", "tags": []}, + {"code": "NE", "tags": ["Africa", "WestAfrica"]}, + {"code": "NF", "tags": []}, + {"code": "NG", "tags": ["Africa", "WestAfrica"]}, + {"code": "NZ", "tags": ["Oceania"]}, + {"code": "NP", "tags": ["Asia"]}, + {"code": "NR", "tags": ["Oceania"]}, + {"code": "NU", "tags": []}, + {"code": "CK", "tags": ["Oceania"]}, + {"code": "XK", "tags": ["Europe", "Balkans"]}, + {"code": "CI", "tags": ["Africa", "WestAfrica"]}, + {"code": "CH", "tags": ["Europe"]}, + {"code": "CO", "tags": ["SouthAmerica"]}, + {"code": "CN", "tags": ["Asia"]}, + {"code": "CM", "tags": ["Africa", "CentralAfrica"]}, + {"code": "CL", "tags": ["SouthAmerica"]}, + {"code": "CC", "tags": []}, + {"code": "CA", "tags": ["NorthAmerica"]}, + {"code": "CG", "tags": ["Africa", "CentralAfrica"]}, + {"code": "CF", "tags": ["Africa", "CentralAfrica"]}, + {"code": "CD", "tags": ["Africa", "CentralAfrica"]}, + {"code": "CZ", "tags": ["Europe", "NatoMembers"]}, + {"code": "CY", "tags": ["Europe", "Asia", "MiddleEast"]}, + {"code": "CX", "tags": []}, + {"code": "CR", "tags": ["CentralAmerica"]}, + {"code": "CW", "tags": ["Europe"]}, + {"code": "CV", "tags": ["Africa", "WestAfrica"]}, + {"code": "CU", "tags": ["Caribbean"]}, + {"code": "SZ", "tags": ["Africa", "SouthernAfrica"]}, + {"code": "SY", "tags": ["Asia", "MiddleEast"]}, + {"code": "SX", "tags": ["Caribbean"]}, + {"code": "KG", "tags": ["Asia", "CentralAsia"]}, + {"code": "KE", "tags": ["Africa", "EastAfrica"]}, + {"code": "SS", "tags": ["Africa", "EastAfrica"]}, + {"code": "SR", "tags": ["SouthAmerica"]}, + {"code": "KI", "tags": ["Oceania"]}, + {"code": "KH", "tags": ["Asia", "SoutheastAsia"]}, + {"code": "KN", "tags": ["Caribbean"]}, + {"code": "KM", "tags": ["Africa", "EastAfrica"]}, + {"code": "ST", "tags": ["Africa", "CentralAfrica"]}, + {"code": "SK", "tags": ["Europe"]}, + {"code": "KR", "tags": ["Asia"]}, + {"code": "SI", "tags": ["Europe", "Balkans"]}, + {"code": "KP", "tags": ["Asia"]}, + {"code": "KW", "tags": ["Asia", "MiddleEast"]}, + {"code": "SN", "tags": ["Africa", "WestAfrica"]}, + {"code": "SM", "tags": ["Europe"]}, + {"code": "SL", "tags": ["Africa", "WestAfrica"]}, + {"code": "SC", "tags": ["Africa", "EastAfrica"]}, + {"code": "KZ", "tags": ["Asia", "CentralAsia"]}, + {"code": "KY", "tags": []}, + {"code": "SG", "tags": ["Asia", "SoutheastAsia"]}, + {"code": "SE", "tags": ["Europe"]}, + {"code": "SD", "tags": ["Africa", "NorthAfrica"]}, + {"code": "DO", "tags": ["Caribbean"]}, + {"code": "DM", "tags": ["Caribbean"]}, + {"code": "DJ", "tags": ["Africa", "EastAfrica"]}, + {"code": "DK", "tags": ["Europe"]}, + {"code": "VG", "tags": []}, + {"code": "DE", "tags": ["Europe"]}, + {"code": "YE", "tags": ["Asia", "MiddleEast"]}, + {"code": "DZ", "tags": ["Africa", "NorthAfrica"]}, + {"code": "US", "tags": ["NorthAmerica"]}, + {"code": "UY", "tags": ["SouthAmerica"]}, + {"code": "YT", "tags": []}, + {"code": "UM", "tags": []}, + {"code": "LB", "tags": ["Asia", "MiddleEast"]}, + {"code": "LC", "tags": ["Caribbean"]}, + {"code": "LA", "tags": ["Asia", "SoutheastAsia"]}, + {"code": "TV", "tags": ["Oceania"]}, + {"code": "TW", "tags": ["Asia"]}, + {"code": "TT", "tags": ["Caribbean"]}, + {"code": "TR", "tags": ["Europe", "Asia", "MiddleEast"]}, + {"code": "LK", "tags": ["Asia"]}, + {"code": "LI", "tags": ["Europe"]}, + {"code": "LV", "tags": ["Europe"]}, + {"code": "TO", "tags": ["Oceania"]}, + {"code": "LT", "tags": ["Europe"]}, + {"code": "LU", "tags": ["Europe"]}, + {"code": "LR", "tags": ["Africa", "WestAfrica"]}, + {"code": "LS", "tags": ["Africa", "SouthernAfrica"]}, + {"code": "TH", "tags": ["Asia", "SoutheastAsia"]}, + {"code": "TF", "tags": []}, + {"code": "TG", "tags": ["Africa", "WestAfrica"]}, + {"code": "TD", "tags": ["Africa", "CentralAfrica"]}, + {"code": "TC", "tags": ["Caribbean"]}, + {"code": "LY", "tags": ["Africa", "NorthAfrica"]}, + {"code": "VA", "tags": ["Europe"]}, + {"code": "VC", "tags": ["Caribbean"]}, + {"code": "AE", "tags": ["Asia", "MiddleEast"]}, + {"code": "AD", "tags": ["Europe"]}, + {"code": "AG", "tags": ["Caribbean"]}, + {"code": "AF", "tags": ["Asia", "MiddleEast", "CentralAsia"]}, + {"code": "AI", "tags": ["North America", "Caribbean"]}, + {"code": "VI", "tags": []}, + {"code": "IS", "tags": ["Europe"]}, + {"code": "IR", "tags": []}, + {"code": "AM", "tags": ["Middle East", "Asia"]}, + {"code": "AL", "tags": ["Europe", "Balkans"]}, + {"code": "AO", "tags": ["Africa", "CentralAfrica"]}, + {"code": "AQ", "tags": []}, + {"code": "AS", "tags": ["Oceania"]}, + {"code": "AR", "tags": ["SouthAmerica"]}, + {"code": "AU", "tags": ["Oceania"]}, + {"code": "AT", "tags": ["Europe"]}, + {"code": "AW", "tags": ["Europe"]}, + {"code": "IN", "tags": ["Asia"]}, + {"code": "AX", "tags": ["Europe"]}, + {"code": "AZ", "tags": ["MiddleEast", "Asia"]}, + {"code": "IE", "tags": ["Europe"]}, + {"code": "ID", "tags": ["Asia", "Oceania", "SoutheastAsia"]}, + {"code": "UA", "tags": ["Europe"]}, + {"code": "QA", "tags": ["Asia", "MiddleEast"]}, + {"code": "MZ", "tags": ["Africa", "EastAfrica"]} +] diff --git a/internal/apps/flags/data/tags.json b/internal/apps/flags/data/tags.json new file mode 100644 index 0000000..413bdc4 --- /dev/null +++ b/internal/apps/flags/data/tags.json @@ -0,0 +1,19 @@ +[ + "Asia", + "MiddleEast", + "SoutheastAsia", + "CentralAsia", + "Europe", + "Balkans", + "NorthAmerica", + "SouthAmerica", + "CentralAmerica", + "Caribbean", + "Africa", + "NorthAfrica", + "SouthernAfrica", + "WestAfrica", + "EastAfrica", + "CentralAfrica", + "Oceania" +] diff --git a/internal/apps/flags/handlers.go b/internal/apps/flags/handlers.go new file mode 100644 index 0000000..0cfcbd5 --- /dev/null +++ b/internal/apps/flags/handlers.go @@ -0,0 +1 @@ +package flags diff --git a/internal/apps/flags/locales/en.json b/internal/apps/flags/locales/en.json new file mode 100644 index 0000000..3c0ce1a --- /dev/null +++ b/internal/apps/flags/locales/en.json @@ -0,0 +1,269 @@ +{ + "Asia": "Asia", + "MiddleEast": "Middle East", + "SoutheastAsia": "Southeast Asia", + "CentralAsia": "Central Asia", + "Europe": "Europe", + "Balkans": "Balkans", + "NorthAmerica": "North America", + "SouthAmerica": "South America", + "CentralAmerica": "Central America", + "Caribbean": "Caribbean", + "Africa": "Africa", + "NorthAfrica": "North Africa", + "SouthernAfrica": "Southern Africa", + "WestAfrica": "West Africa", + "EastAfrica": "East Africa", + "CentralAfrica": "Central Africa", + "Oceania": "Oceania", + "BD": "Bangladesh", + "BE": "Belgium", + "BF": "Burkina Faso", + "BG": "Bulgaria", + "BA": "Bosnia and Herzegovina", + "BB": "Barbados", + "WF": "Wallis and Futuna", + "BL": "Saint Barthelemy", + "BM": "Bermuda", + "BN": "Brunei", + "BO": "Bolivia", + "BH": "Bahrain", + "BI": "Burundi", + "BJ": "Benin", + "BT": "Bhutan", + "JM": "Jamaica", + "BV": "Bouvet Island", + "BW": "Botswana", + "WS": "Samoa", + "BQ": "Caribbean Netherlands", + "BR": "Brazil", + "BS": "Bahamas", + "JE": "Jersey", + "BY": "Belarus", + "BZ": "Belize", + "RU": "Russia", + "RW": "Rwanda", + "RS": "Serbia", + "TL": "East Timor", + "RE": "Reunion", + "TM": "Turkmenistan", + "TJ": "Tajikistan", + "RO": "Romania", + "TK": "Tokelau", + "GW": "Guinea-Bissau", + "GU": "Guam", + "GT": "Guatemala", + "GS": "South Georgia and the South Sandwich Islands", + "GR": "Greece", + "GQ": "Equatorial Guinea", + "GP": "Guadeloupe", + "JP": "Japan", + "GY": "Guyana", + "GG": "Guernsey", + "GF": "French Guiana", + "GE": "Georgia", + "GD": "Grenada", + "GB": "United Kingdom", + "GA": "Gabon", + "SV": "El Salvador", + "GN": "Guinea", + "GM": "Gambia", + "GL": "Greenland", + "GI": "Gibraltar", + "GH": "Ghana", + "OM": "Oman", + "TN": "Tunisia", + "JO": "Jordan", + "HR": "Croatia", + "HT": "Haiti", + "HU": "Hungary", + "HK": "Hong Kong", + "HN": "Honduras", + "HM": "Heard Island and McDonald Islands", + "VE": "Venezuela", + "PR": "Puerto Rico", + "PS": "Palestine", + "PW": "Palau", + "PT": "Portugal", + "SJ": "Svalbard and Jan Mayen", + "PY": "Paraguay", + "IQ": "Iraq", + "PA": "Panama", + "PF": "French Polynesia", + "PG": "Papua New Guinea", + "PE": "Peru", + "PK": "Pakistan", + "PH": "Philippines", + "PN": "Pitcairn", + "PL": "Poland", + "PM": "Saint Pierre and Miquelon", + "ZM": "Zambia", + "EH": "Western Sahara", + "EE": "Estonia", + "EG": "Egypt", + "ZA": "South Africa", + "EC": "Ecuador", + "IT": "Italy", + "VN": "Vietnam", + "SB": "Solomon Islands", + "ET": "Ethiopia", + "SO": "Somalia", + "ZW": "Zimbabwe", + "SA": "Saudi Arabia", + "ES": "Spain", + "ER": "Eritrea", + "ME": "Montenegro", + "MD": "Moldova", + "MG": "Madagascar", + "MF": "Saint Martin", + "MA": "Morocco", + "MC": "Monaco", + "UZ": "Uzbekistan", + "MM": "Myanmar", + "ML": "Mali", + "MO": "Macao", + "MN": "Mongolia", + "MH": "Marshall Islands", + "MK": "Macedonia", + "MU": "Mauritius", + "MT": "Malta", + "MW": "Malawi", + "MV": "Maldives", + "MQ": "Martinique", + "MP": "Northern Mariana Islands", + "MS": "Montserrat", + "MR": "Mauritania", + "IM": "Isle of Man", + "UG": "Uganda", + "TZ": "Tanzania", + "MY": "Malaysia", + "MX": "Mexico", + "IL": "Israel", + "FR": "France", + "IO": "British Indian Ocean Territory", + "SH": "Saint Helena", + "FI": "Finland", + "FJ": "Fiji", + "FK": "Falkland Islands", + "FM": "Micronesia", + "FO": "Faroe Islands", + "NI": "Nicaragua", + "NL": "Netherlands", + "NO": "Norway", + "NA": "Namibia", + "VU": "Vanuatu", + "NC": "New Caledonia", + "NE": "Niger", + "NF": "Norfolk Island", + "NG": "Nigeria", + "NZ": "New Zealand", + "NP": "Nepal", + "NR": "Nauru", + "NU": "Niue", + "CK": "Cook Islands", + "XK": "Kosovo", + "CI": "Ivory Coast", + "CH": "Switzerland", + "CO": "Colombia", + "CN": "China", + "CM": "Cameroon", + "CL": "Chile", + "CC": "Cocos Islands", + "CA": "Canada", + "CG": "Republic of the Congo", + "CF": "Central African Republic", + "CD": "Democratic Republic of the Congo", + "CZ": "Czech Republic", + "CY": "Cyprus", + "CX": "Christmas Island", + "CR": "Costa Rica", + "CW": "Curacao", + "CV": "Cape Verde", + "CU": "Cuba", + "SZ": "Swaziland", + "SY": "Syria", + "SX": "Sint Maarten", + "KG": "Kyrgyzstan", + "KE": "Kenya", + "SS": "South Sudan", + "SR": "Suriname", + "KI": "Kiribati", + "KH": "Cambodia", + "KN": "Saint Kitts and Nevis", + "KM": "Comoros", + "ST": "Sao Tome and Principe", + "SK": "Slovakia", + "KR": "South Korea", + "SI": "Slovenia", + "KP": "North Korea", + "KW": "Kuwait", + "SN": "Senegal", + "SM": "San Marino", + "SL": "Sierra Leone", + "SC": "Seychelles", + "KZ": "Kazakhstan", + "KY": "Cayman Islands", + "SG": "Singapore", + "SE": "Sweden", + "SD": "Sudan", + "DO": "Dominican Republic", + "DM": "Dominica", + "DJ": "Djibouti", + "DK": "Denmark", + "VG": "British Virgin Islands", + "DE": "Germany", + "YE": "Yemen", + "DZ": "Algeria", + "US": "United States", + "UY": "Uruguay", + "YT": "Mayotte", + "UM": "United States Minor Outlying Islands", + "LB": "Lebanon", + "LC": "Saint Lucia", + "LA": "Laos", + "TV": "Tuvalu", + "TW": "Taiwan", + "TT": "Trinidad and Tobago", + "TR": "Turkey", + "LK": "Sri Lanka", + "LI": "Liechtenstein", + "LV": "Latvia", + "TO": "Tonga", + "LT": "Lithuania", + "LU": "Luxembourg", + "LR": "Liberia", + "LS": "Lesotho", + "TH": "Thailand", + "TF": "French Southern Territories", + "TG": "Togo", + "TD": "Chad", + "TC": "Turks and Caicos Islands", + "LY": "Libya", + "VA": "Vatican", + "VC": "Saint Vincent and the Grenadines", + "AE": "United Arab Emirates", + "AD": "Andorra", + "AG": "Antigua and Barbuda", + "AF": "Afghanistan", + "AI": "Anguilla", + "VI": "U.S. Virgin Islands", + "IS": "Iceland", + "IR": "Iran", + "AM": "Armenia", + "AL": "Albania", + "AO": "Angola", + "AQ": "Antarctica", + "AS": "American Samoa", + "AR": "Argentina", + "AU": "Australia", + "AT": "Austria", + "AW": "Aruba", + "IN": "India", + "AX": "Aland Islands", + "AZ": "Azerbaijan", + "IE": "Ireland", + "ID": "Indonesia", + "UA": "Ukraine", + "QA": "Qatar", + "MZ": "Mozambique" +} diff --git a/internal/apps/flags/locales/nl.json b/internal/apps/flags/locales/nl.json new file mode 100644 index 0000000..da27f8f --- /dev/null +++ b/internal/apps/flags/locales/nl.json @@ -0,0 +1,269 @@ +{ + "Asia": "Azië", + "MiddleEast": "Midden-Oosten", + "SoutheastAsia": "Zuidoost-Azië", + "CentralAsia": "Centraal-Azië", + "Europe": "Europa", + "Balkans": "Balkan", + "NorthAmerica": "Noord-Amerika", + "SouthAmerica": "Zuid-Amerika", + "CentralAmerica": "Midden-Amerika", + "Caribbean": "Caraïben", + "Africa": "Afrika", + "NorthAfrica": "Noord-Afrika", + "SouthernAfrica": "Zuid-Afrika", + "WestAfrica": "West-Afrika", + "EastAfrica": "Oost-Afrika", + "CentralAfrica": "Centraal-Afrika", + "Oceania": "Oceanië", + "BD": "Bangladesh", + "BE": "België", + "BF": "Burkina Faso", + "BG": "Bulgarije", + "BA": "Bosnië en Herzegovina", + "BB": "Barbados", + "WF": "Wallis en Futuna", + "BL": "Saint-Barthélemy", + "BM": "Bermuda", + "BN": "Brunei", + "BO": "Bolivia", + "BH": "Bahrein", + "BI": "Burundi", + "BJ": "Benin", + "BT": "Bhutan", + "JM": "Jamaica", + "BV": "Bouveteiland", + "BW": "Botswana", + "WS": "Samoa", + "BQ": "Caribisch Nederland", + "BR": "Brazilië", + "BS": "Bahamas", + "JE": "Jersey", + "BY": "Wit-Rusland", + "BZ": "Belize", + "RU": "Rusland", + "RW": "Rwanda", + "RS": "Servië", + "TL": "Oost-Timor", + "RE": "Réunion", + "TM": "Turkmenistan", + "TJ": "Tadzjikistan", + "RO": "Roemenië", + "TK": "Tokelau-eilanden", + "GW": "Guinee-Bissau", + "GU": "Guam", + "GT": "Guatemala", + "GS": "Zuid-Georgië en Zuidelijke Sandwicheilanden", + "GR": "Griekenland", + "GQ": "Equatoriaal-Guinea", + "GP": "Guadeloupe", + "JP": "Japan", + "GY": "Guyana", + "GG": "Guernsey", + "GF": "Frans-Guyana", + "GE": "Georgië", + "GD": "Grenada", + "GB": "Verenigd Koninkrijk", + "GA": "Gabon", + "SV": "El Salvador", + "GN": "Guinee", + "GM": "Gambia", + "GL": "Groenland", + "GI": "Gibraltar", + "GH": "Ghana", + "OM": "Oman", + "TN": "Tunesië", + "JO": "Jordanië", + "HR": "Kroatië", + "HT": "Haïti", + "HU": "Hongarije", + "HK": "Hongkong", + "HN": "Honduras", + "HM": "Heard- en McDonaldeilanden", + "VE": "Venezuela", + "PR": "Porto Rico", + "PS": "Palestina", + "PW": "Palau", + "PT": "Portugal", + "SJ": "Svalbard en Jan Mayen", + "PY": "Paraguay", + "IQ": "Irak", + "PA": "Panama", + "PF": "Frans-Polynesië", + "PG": "Papoea-Nieuw-Guinea", + "PE": "Peru", + "PK": "Pakistan", + "PH": "Filipijnen", + "PN": "Pitcairneilanden", + "PL": "Polen", + "PM": "Saint-Pierre en Miquelon", + "ZM": "Zambia", + "EH": "Westelijke Sahara", + "EE": "Estland", + "EG": "Egypte", + "ZA": "Zuid-Afrika", + "EC": "Ecuador", + "IT": "Italië", + "VN": "Vietnam", + "SB": "Salomonseilanden", + "ET": "Ethiopië", + "SO": "Somalië", + "ZW": "Zimbabwe", + "SA": "Saoedi-Arabië", + "ES": "Spanje", + "ER": "Eritrea", + "ME": "Montenegro", + "MD": "Moldavië", + "MG": "Madagaskar", + "MF": "Sint-Maarten (Franse Antillen)", + "MA": "Marokko", + "MC": "Monaco", + "UZ": "Oezbekistan", + "MM": "Myanmar", + "ML": "Mali", + "MO": "Macau", + "MN": "Mongolië", + "MH": "Marshalleilanden", + "MK": "Noord-Macedonië", + "MU": "Mauritius", + "MT": "Malta", + "MW": "Malawi", + "MV": "Maldiven", + "MQ": "Martinique", + "MP": "Noordelijke Marianen", + "MS": "Montserrat", + "MR": "Mauritanië", + "IM": "Isle of Man", + "UG": "Oeganda", + "TZ": "Tanzania", + "MY": "Maleisië", + "MX": "Mexico", + "IL": "Israël", + "FR": "Frankrijk", + "IO": "Brits Territorium in de Indische Oceaan", + "SH": "Sint-Helena", + "FI": "Finland", + "FJ": "Fiji", + "FK": "Falklandeilanden", + "FM": "Micronesia", + "FO": "Faeröer", + "NI": "Nicaragua", + "NL": "Nederland", + "NO": "Noorwegen", + "NA": "Namibië", + "VU": "Vanuatu", + "NC": "Nieuw-Caledonië", + "NE": "Niger", + "NF": "Norfolkeiland", + "NG": "Nigeria", + "NZ": "Nieuw-Zeeland", + "NP": "Nepal", + "NR": "Nauru", + "NU": "Niue", + "CK": "Cookeilanden", + "XK": "Kosovo", + "CI": "Ivoorkust", + "CH": "Zwitserland", + "CO": "Colombia", + "CN": "China", + "CM": "Kameroen", + "CL": "Chili", + "CC": "Cocoseilanden", + "CA": "Canada", + "CG": "Congo", + "CF": "Centraal-Afrikaanse Republiek", + "CD": "Democratische Republiek Congo", + "CZ": "Tsjechië", + "CY": "Cyprus", + "CX": "Christmaseiland", + "CR": "Costa Rica", + "CW": "Curacao", + "CV": "Kaapverdië", + "CU": "Cuba", + "SZ": "Swaziland", + "SY": "Syrië", + "SX": "Sint Maarten", + "KG": "Kirgizstan", + "KE": "Kenia", + "SS": "Zuid-Soedan", + "SR": "Suriname", + "KI": "Kiribati", + "KH": "Cambodja", + "KN": "Saint Kitts en Nevis", + "KM": "Comoren", + "ST": "Sao Tomé en Principe", + "SK": "Slovakije", + "KR": "Zuid-Korea", + "SI": "Slovenië", + "KP": "Noord-Korea", + "KW": "Koeweit", + "SN": "Senegal", + "SM": "San Marino", + "SL": "Sierra Leone", + "SC": "Seychellen", + "KZ": "Kazachstan", + "KY": "Caymaneilanden", + "SG": "Singapore", + "SE": "Zweden", + "SD": "Soedan", + "DO": "Dominicaanse Republiek", + "DM": "Dominica", + "DJ": "Djibouti", + "DK": "Denemarken", + "VG": "Britse Maagdeneilanden", + "DE": "Duitsland", + "YE": "Jemen", + "DZ": "Algerije", + "US": "Verenigde Staten", + "UY": "Uruguay", + "YT": "Mayotte", + "UM": "Amerikaanse ondergeschikte afgelegen eilanden", + "LB": "Libanon", + "LC": "Saint Lucia", + "LA": "Laos", + "TV": "Tuvalu", + "TW": "Taiwan", + "TT": "Trinidad en Tobago", + "TR": "Turkije", + "LK": "Sri Lanka", + "LI": "Liechtenstein", + "LV": "Letland", + "TO": "Tonga", + "LT": "Litouwen", + "LU": "Luxemburg", + "LR": "Liberia", + "LS": "Lesotho", + "TH": "Thailand", + "TF": "Franse Gebieden in de zuidelijke Indische Oceaan", + "TG": "Togo", + "TD": "Tsjaad", + "TC": "Turks- en Caicoseilanden", + "LY": "Libië", + "VA": "Vaticaanstad", + "VC": "Saint Vincent en de Grenadines", + "AE": "Verenigde Arabische Emiraten", + "AD": "Andorra", + "AG": "Antigua en Barbuda", + "AF": "Afghanistan", + "AI": "Anguilla", + "VI": "Amerikaanse Maagdeneilanden", + "IS": "IJsland", + "IR": "Iran", + "AM": "Armenië", + "AL": "Albanië", + "AO": "Angola", + "AQ": "Antarctica", + "AS": "Amerikaans-Samoa", + "AR": "Argentinië", + "AU": "Australië", + "AT": "Oostenrijk", + "AW": "Aruba", + "IN": "India", + "AX": "Åland", + "AZ": "Azerbeidzjan", + "IE": "Ierland", + "ID": "Indonesië", + "UA": "Oekraïne", + "QA": "Qatar", + "MZ": "Mozambique" +} diff --git a/internal/apps/flags/main.go b/internal/apps/flags/main.go new file mode 100644 index 0000000..452ceea --- /dev/null +++ b/internal/apps/flags/main.go @@ -0,0 +1,68 @@ +package flags + +// WIP + +import ( + "embed" + "encoding/json" + + "git.tijl.dev/tijl/tijl.dev-core/modules/i18n" + log "git.tijl.dev/tijl/tijl.dev-core/modules/logger" + "git.tijl.dev/tijl/tijl.dev-core/modules/web" + "github.com/gofiber/fiber/v2" +) + +var supportedTags []string +var countryCodes []CountryCode + +type CountryCode struct { + Code string `json:"code"` + Tags []string `json:"tags"` +} + +//go:embed locales/* data/* +var Embed embed.FS + +func Setup() { + i18n.RegisterTranslations(Embed, "locales") + + err := loadData() + if err != nil { + log.Error().Err(err).Msg("error loading country codes data file") + } + + web.RegisterAppSetupFunc(func(a *fiber.App) { + a.Get("/app/flags", func(c *fiber.Ctx) error { + data := *web.Common(c) + data["Title"] = "tmp" + data["SupportedTags"] = supportedTags + return c.Render("apps/flags/start", data, "layouts/base") + }) + }, 1000) +} + +func loadData() error { + countryCodesData, err := Embed.ReadFile("data/country_codes.json") + if err != nil { + return err + } + + countryCodes = []CountryCode{} + err = json.Unmarshal(countryCodesData, &countryCodes) + if err != nil { + return err + } + + tagsData, err := Embed.ReadFile("data/tags.json") + if err != nil { + return err + } + + supportedTags = []string{} + err = json.Unmarshal(tagsData, &supportedTags) + if err != nil { + return err + } + + return nil +} diff --git a/internal/handlers/auth.go b/internal/handlers/auth.go index 404646f..5fef704 100644 --- a/internal/handlers/auth.go +++ b/internal/handlers/auth.go @@ -44,7 +44,7 @@ func authHandler(c *fiber.Ctx) error { func logoutHandler(c *fiber.Ctx) error { _, err := user.GetSession(c) if err == nil { - c.ClearCookie("session") + c.ClearCookie("session", "state") return c.Redirect("/login", http.StatusOK) } else { return c.Redirect("/login", http.StatusUnauthorized) diff --git a/internal/handlers/routes.go b/internal/handlers/routes.go index 3496345..7860459 100644 --- a/internal/handlers/routes.go +++ b/internal/handlers/routes.go @@ -6,6 +6,7 @@ import ( "git.tijl.dev/tijl/tijl.dev-core/internal/config" "git.tijl.dev/tijl/tijl.dev-core/internal/oidc" + "git.tijl.dev/tijl/tijl.dev-core/internal/user" "git.tijl.dev/tijl/tijl.dev-core/modules/i18n" "git.tijl.dev/tijl/tijl.dev-core/modules/web" webf "git.tijl.dev/tijl/tijl.dev-core/web" @@ -15,7 +16,8 @@ import ( func Setup() { LoadPosts() - web.RegisterAppSetupFunc(routes) + web.RegisterAppSetupFunc(routes, 100) + web.RegisterAppSetupFunc(last, 0) } func routes(app *fiber.App) { @@ -38,10 +40,10 @@ func routes(app *fiber.App) { return c.Render("about", data, "layouts/base") }) app.Get("/services", func(c *fiber.Ctx) error { - /*_, err := user.GetSession(c) + _, err := user.GetSession(c) if err != nil { return c.Next() - }*/ + } data := *web.Common(c) data["Title"] = i18n.Translate(c, "services") return c.Render("services", data, "layouts/base") @@ -62,7 +64,10 @@ func routes(app *fiber.App) { app.Use("/static/", filesystem.New(filesystem.Config{ Root: http.FS(static), })) +} +// last function with low priority for 404 handler +func last(app *fiber.App) { /* 404 */ @@ -70,5 +75,4 @@ func routes(app *fiber.App) { data := *web.Common(c) return c.Render("404", data, "layouts/base") }) - } diff --git a/internal/oidc/handler.go b/internal/oidc/handler.go index 5eba5b6..5d6059c 100644 --- a/internal/oidc/handler.go +++ b/internal/oidc/handler.go @@ -82,11 +82,9 @@ func HandleCallback(c *fiber.Ctx) error { } redirect := c.Cookies("internal_redirect") - log.Debug().Msg(redirect) + c.ClearCookie("internal_redirect", "state") if redirect != "" { - c.ClearCookie("internal_redirect") - return c.Redirect(redirect) + return c.Redirect(redirect, http.StatusFound) } - - return c.Redirect("/loggedin") + return c.Redirect("/loggedin", http.StatusFound) } diff --git a/internal/queries/app_flags.sql b/internal/queries/app_flags.sql new file mode 100644 index 0000000..a430d1e --- /dev/null +++ b/internal/queries/app_flags.sql @@ -0,0 +1,9 @@ +-- name: CreateFlagsGame :exec +INSERT INTO app_flags_games (uid, tags, question_amount) VALUES ($1, $2, $3) RETURNING (game_id, game_seed); + +-- name: GetFlagsGame :one +SELECT * FROM app_flags_games WHERE game_id = $1 LIMIT 1; + +-- name: UpdateFlagsGame :exec +UPDATE app_flags_games SET question_current = $1, +last_activity = CURRENT_TIMESTAMP; diff --git a/internal/queries/app_flags.sql.go b/internal/queries/app_flags.sql.go new file mode 100644 index 0000000..76d3c89 --- /dev/null +++ b/internal/queries/app_flags.sql.go @@ -0,0 +1,60 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.27.0 +// source: app_flags.sql + +package queries + +import ( + "context" + "database/sql" + + "github.com/google/uuid" + "github.com/lib/pq" +) + +const createFlagsGame = `-- name: CreateFlagsGame :exec +INSERT INTO app_flags_games (uid, tags, question_amount) VALUES ($1, $2, $3) RETURNING (game_id, game_seed) +` + +type CreateFlagsGameParams struct { + Uid sql.NullString + Tags []string + QuestionAmount int32 +} + +func (q *Queries) CreateFlagsGame(ctx context.Context, arg CreateFlagsGameParams) error { + _, err := q.db.ExecContext(ctx, createFlagsGame, arg.Uid, pq.Array(arg.Tags), arg.QuestionAmount) + return err +} + +const getFlagsGame = `-- name: GetFlagsGame :one +SELECT game_id, game_seed, uid, tags, question_amount, question_current, question_correct, created_at, last_activity FROM app_flags_games WHERE game_id = $1 LIMIT 1 +` + +func (q *Queries) GetFlagsGame(ctx context.Context, gameID uuid.UUID) (AppFlagsGame, error) { + row := q.db.QueryRowContext(ctx, getFlagsGame, gameID) + var i AppFlagsGame + err := row.Scan( + &i.GameID, + &i.GameSeed, + &i.Uid, + pq.Array(&i.Tags), + &i.QuestionAmount, + &i.QuestionCurrent, + &i.QuestionCorrect, + &i.CreatedAt, + &i.LastActivity, + ) + return i, err +} + +const updateFlagsGame = `-- name: UpdateFlagsGame :exec +UPDATE app_flags_games SET question_current = $1, +last_activity = CURRENT_TIMESTAMP +` + +func (q *Queries) UpdateFlagsGame(ctx context.Context, questionCurrent int32) error { + _, err := q.db.ExecContext(ctx, updateFlagsGame, questionCurrent) + return err +} diff --git a/internal/queries/models.go b/internal/queries/models.go index 22d71bd..d9cf217 100644 --- a/internal/queries/models.go +++ b/internal/queries/models.go @@ -7,8 +7,28 @@ package queries import ( "database/sql" "time" + + "github.com/google/uuid" ) +type AppFlagsGame struct { + GameID uuid.UUID + GameSeed uuid.NullUUID + Uid sql.NullString + Tags []string + QuestionAmount int32 + QuestionCurrent int32 + QuestionCorrect sql.NullInt32 + CreatedAt time.Time + LastActivity time.Time +} + +type AppFlagsGamesAnswer struct { + GameID uuid.NullUUID + Question int32 + Correct bool +} + type Session struct { ID int32 Uid string diff --git a/internal/service/main.go b/internal/service/main.go index c4b4540..7fe3f1f 100644 --- a/internal/service/main.go +++ b/internal/service/main.go @@ -5,6 +5,7 @@ import ( "fmt" "net/http" + "git.tijl.dev/tijl/tijl.dev-core/internal/apps/flags" "git.tijl.dev/tijl/tijl.dev-core/internal/assets" "git.tijl.dev/tijl/tijl.dev-core/internal/config" "git.tijl.dev/tijl/tijl.dev-core/internal/handlers" @@ -39,6 +40,10 @@ func Listen() { i18n.RegisterTranslations(locales.Embed, ".") // setup handler handlers.Setup() + + // setup apps + flags.Setup() + // setup web webinternal.Load() diff --git a/migrations/00000002_flags.down.sql b/migrations/00000002_flags.down.sql new file mode 100644 index 0000000..e69de29 diff --git a/migrations/00000002_flags.up.sql b/migrations/00000002_flags.up.sql new file mode 100644 index 0000000..b80a1a7 --- /dev/null +++ b/migrations/00000002_flags.up.sql @@ -0,0 +1,23 @@ +CREATE TABLE app_flags_games ( + game_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + game_seed UUID DEFAULT gen_random_uuid(), + uid VARCHAR DEFAULT NULL, + tags VARCHAR[] NOT NULL, + question_amount INT NOT NULL, + question_current INT DEFAULT 0 NOT NULL, + question_correct INT GENERATED ALWAYS AS ( + (SELECT COUNT(*) FROM app_flags_games_answers a WHERE a.game_id = app_flags_games.game_id AND a.correct = TRUE) + ) STORED, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + last_activity TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (uid) REFERENCES users (uid) +); + +CREATE TABLE app_flags_games_answers ( + game_id UUID, + question INT NOT NULL, + correct BOOLEAN NOT NULL, + FOREIGN KEY (game_id) REFERENCES app_flags_games (game_id), + CONSTRAINT app_flags_games_answers_unique UNIQUE (game_id, question) +); + diff --git a/modules/i18n/i18n.go b/modules/i18n/i18n.go index 53d6d25..3bc5707 100644 --- a/modules/i18n/i18n.go +++ b/modules/i18n/i18n.go @@ -15,6 +15,7 @@ var translations map[string]map[string]string const DefaultLang = "en" func RegisterTranslations(embed embed.FS, location string) { + amountFilesLoaded := 0 if translations == nil { translations = make(map[string]map[string]string) } @@ -56,8 +57,11 @@ func RegisterTranslations(embed embed.FS, location string) { translations[lang][key] = value } - log.Debug().Str("filename", file.Name()).Msg("i18n.RegisterTranslations: loaded") + amountFilesLoaded++ + //log.Debug().Str("filename", file.Name()).Msg("i18n.RegisterTranslations: loaded") } + + log.Debug().Int("amountFilesLoaded", amountFilesLoaded).Msg("i18n.RegisterTranslations:") } func Translate(c *fiber.Ctx, key string) string { diff --git a/modules/logger/logger.go b/modules/logger/logger.go index 05c3ce8..5e24fbf 100644 --- a/modules/logger/logger.go +++ b/modules/logger/logger.go @@ -11,8 +11,7 @@ var ( ) func Load() { - Logger = zerolog.New(os.Stderr).With().Timestamp().Logger().Output(zerolog.ConsoleWriter{Out: os.Stderr}) - Logger.Level(zerolog.DebugLevel) + Logger = zerolog.New(os.Stderr).With().Timestamp().Logger().Output(zerolog.ConsoleWriter{Out: os.Stderr}).Level(zerolog.DebugLevel) } func Info() *zerolog.Event { diff --git a/modules/web/app.go b/modules/web/app.go index c3ecd21..1a6173a 100644 --- a/modules/web/app.go +++ b/modules/web/app.go @@ -1,6 +1,8 @@ package web import ( + "sort" + log "git.tijl.dev/tijl/tijl.dev-core/modules/logger" "github.com/gofiber/fiber/v2" ) @@ -9,17 +11,29 @@ import ( Basic system for being able to add routes from other packages */ -var setupFuncs []func(*fiber.App) +type setupFuncWithPriority struct { + function func(*fiber.App) + priority int +} -func RegisterAppSetupFunc(function func(*fiber.App)) { +var setupFuncs []setupFuncWithPriority + +func RegisterAppSetupFunc(function func(*fiber.App), priority int) { log.Debug().Msg("web.RegisterAppSetupFunc: registered a function") - setupFuncs = append(setupFuncs, function) + setupFuncs = append(setupFuncs, setupFuncWithPriority{ + function: function, + priority: priority, + }) } +// Setup executes all registered functions in order of priority func Setup(app *fiber.App) { + sort.SliceStable(setupFuncs, func(i, j int) bool { + return setupFuncs[i].priority > setupFuncs[j].priority + }) - for _, function := range setupFuncs { - function(app) + for _, setupFunc := range setupFuncs { + // log.Debug().Msg("web.Setup: executing a function") + setupFunc.function(app) } - } diff --git a/web/views/apps/flags/start.html b/web/views/apps/flags/start.html new file mode 100644 index 0000000..8f107c6 --- /dev/null +++ b/web/views/apps/flags/start.html @@ -0,0 +1,8 @@ +
+ {{range .SupportedTags}} + + {{end}} +