diff --git a/basic/basic.go b/basic/basic.go index 4747a9526ba9f666ceae1e5a327617dd22a77e3e..eb95cd1c5626710b31abff792156e1c0f374d358 100644 --- a/basic/basic.go +++ b/basic/basic.go @@ -1,3 +1,15 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package basic import ( @@ -21,7 +33,7 @@ import ( const ( - rsrcDir = "skillsClient" + rsrcDir = "skillsclient" serverDefaultAddress = "http://localhost:8081" serverAddressName = "serverAddress.txt" @@ -29,7 +41,9 @@ const ( htmlDefaultAddress = "localhost:7071" htmlAddressName = "htmlAddress.txt" + skillsclientName = "skillsclient" adminsName = "skillsclient/admins.txt" + adminsDef = "gerard94" passLength = 12 @@ -60,6 +74,7 @@ var ( serverAddress = serverDefaultAddress htmlAddress = htmlDefaultAddress + skillsclientPath = R.FindDir(skillsclientName) adminsPath = R.FindDir(adminsName) admins []string @@ -85,12 +100,24 @@ func CleanText (text string) string { } //CleanText func readAdmins () { - f, err := os.Open(adminsPath); M.Assert(err == nil, err, 100) - defer f.Close() - sc := bufio.NewScanner(f) - admins = make([]string, 0) - for sc.Scan() { - admins = append(admins, CleanText(sc.Text())) + f, err := os.Open(adminsPath) + if err == nil { + defer f.Close() + sc := bufio.NewScanner(f) + admins = make([]string, 0) + for sc.Scan() { + t := CleanText(sc.Text()) + if t != "" { + admins = append(admins, t) + } + } + } else { + f, err := os.Create(adminsPath) + M.Assert(err == nil, err, 100) + defer f.Close() + fmt.Fprint(f, adminsDef) + admins = make([]string, 1) + admins[0] = adminsDef } } @@ -190,7 +217,7 @@ func fixAddress (adrName string, adr *string) { } // fixAddress func init () { - err := os.MkdirAll(rsrcPath, 0777); M.Assert(err == nil, err, 100) + err := os.MkdirAll(skillsclientPath, 0777); M.Assert(err == nil, err, 100) fixAddress(serverAddressName, &serverAddress) fixAddress(htmlAddressName, &htmlAddress) readAdmins() diff --git a/cities/cities.go b/cities/cities.go index 575c69730db7e28db27da06562d7b5ee1914a7f5..7147a65fd33898b0213a3c51b345f8e26cd966ed 100644 --- a/cities/cities.go +++ b/cities/cities.go @@ -1,3 +1,15 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package cities import ( @@ -33,7 +45,7 @@ const ( queryRenameCity = ` mutation CityRename ($co: String!, $rg: String!, $cy: String!, $nN: String!) { - renameLocation(country: $co, region: $rg, city: $cy, newName: $nN) + renameLocation(location: CITY, country: $co, region: $rg, city: $cy, newName: $nN) } ` diff --git a/credentialsCreate/credentialsCreate.go b/credentialsCreate/credentialsCreate.go index b16e8d394698d5cb0c2758dbfea60a7713ec8fd3..36d08af85402ad3861e1ef4430a7a87e70bd3a2d 100644 --- a/credentialsCreate/credentialsCreate.go +++ b/credentialsCreate/credentialsCreate.go @@ -1,3 +1,15 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package credentialsCreate import ( diff --git a/gqSender/gqSender.go b/gqSender/gqSender.go index 21c8ea0b452f258af3d7a3c846cd9940e36fdf7a..e7c93865eb0e910d07b209a5b9b331576a403b35 100644 --- a/gqSender/gqSender.go +++ b/gqSender/gqSender.go @@ -1,7 +1,7 @@ /* -skillsclient. +Skills -Copyright (C) 2017 GérardMeunier +Copyright (C) 2023 GérardMeunier This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. diff --git a/identitiesSearch/identitiesSearch.go b/identitiesSearch/identitiesSearch.go index 477496327a44dd6d5d5cae8ce35ef2e414dfda83..15ce1169cf01ead6fa173d1ac3362881283d9bc4 100644 --- a/identitiesSearch/identitiesSearch.go +++ b/identitiesSearch/identitiesSearch.go @@ -1,3 +1,15 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package identitiesSearch import ( diff --git a/identityChange/IdentityChange.go b/identityChange/IdentityChange.go index 896b6622a3cdb50db5b8977a1a98b24f8382f669..b0386ec688df1f4db862474777d60db123453aeb 100644 --- a/identityChange/IdentityChange.go +++ b/identityChange/IdentityChange.go @@ -1,3 +1,15 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package identityChange import ( diff --git a/identityChangeM/IdentityChangeM.go b/identityChangeM/IdentityChangeM.go index de468846faa172495bb28a42724089bec1ac368d..507034d84215c393bb727390935bf94d2c07405c 100644 --- a/identityChangeM/IdentityChangeM.go +++ b/identityChangeM/IdentityChangeM.go @@ -1,3 +1,15 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package identityChangeM import ( diff --git a/identityRemove/identityRemove.go b/identityRemove/identityRemove.go index 8c06c0dfbf79899ae94a755d6e0511541a61af58..fef2a16faa08102fa1321812564a4529eb12cc17 100644 --- a/identityRemove/identityRemove.go +++ b/identityRemove/identityRemove.go @@ -1,3 +1,15 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package identityRemove import ( diff --git a/language/language.go b/language/language.go index b6ef8c6e3ce00d5274e6a40538a5e80298ae3e6c..a2db3ec779148afcf25999ec63f718ad428bf820 100644 --- a/language/language.go +++ b/language/language.go @@ -1,3 +1,15 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package language import ( diff --git a/locations/locations.go b/locations/locations.go index ee76eb22a7ddbc358c7121ecd2207aa7862b56be..b7c39325b6cb81bcf9ef0ff1ed97b051ce2132c8 100644 --- a/locations/locations.go +++ b/locations/locations.go @@ -1,3 +1,15 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package locations import ( @@ -43,14 +55,14 @@ const ( ` queryRenameCountry = ` - mutation RenameCountry ($co: String!, $nN: String!) { - coRen: renameLocation(country: $co, newName: $nN) + mutation RenameCountry ($co: String!, $rg: String, $nN: String!) { + coRen: renameLocation(location: COUNTRY, country: $co, region: $rg, newName: $nN) } ` queryRenameRegion = ` mutation RenameRegion ($co: String!, $rg: String!, $nN: String!) { - rgRen: renameLocation(country: $co, region: $rg, newName: $nN) + rgRen: renameLocation(location: REGION, country: $co, region: $rg, newName: $nN) } ` @@ -313,6 +325,8 @@ func endCoRen (name string, temp *template.Template, r *http.Request, w http.Res mk.StartObject() mk.PushString(oldCountry) mk.BuildField("co") + mk.PushString(region) + mk.BuildField("rg") mk.PushString(newCountry) mk.BuildField("nN") mk.BuildObject() diff --git a/lockSystem/lockSystem.go b/lockSystem/lockSystem.go index 904ec548df6a6b0a57386bc4dc328c1eb89b2506..47a7b7b79905a10289e3661a0214aacf328e2e25 100644 --- a/lockSystem/lockSystem.go +++ b/lockSystem/lockSystem.go @@ -1,3 +1,15 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package lockSystem import ( diff --git a/runSkillsC/run.go b/runSkillsC/run.go index b117ee6e823fdc7499d7fa182212f57834866ef8..2e2c4a84402f1a1bdd30eaa1b333c8d070326be3 100644 --- a/runSkillsC/run.go +++ b/runSkillsC/run.go @@ -1,3 +1,15 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package main import ( @@ -5,6 +17,7 @@ import ( _ "git.duniter.org/gerard94/util/babel/static" _ "git.duniter.org/gerard94/util/json/static" _ "git.duniter.org/gerard94/util/graphQL/static" + _ "git.duniter.org/gerard94/skillsclient/static" CB "git.duniter.org/gerard94/skillsKeys/cryptoBasic" M "git.duniter.org/gerard94/util/misc" @@ -30,7 +43,7 @@ import ( const ( - version = "1.0.3" + version = "1.0.6" ) diff --git a/scanIdentities/scanIdentities.go b/scanIdentities/scanIdentities.go index d5ce17e6cb53652375185171775498ca9453c218..929442db71f0c5879030c92cd8cf2d0b955097dc 100644 --- a/scanIdentities/scanIdentities.go +++ b/scanIdentities/scanIdentities.go @@ -1,3 +1,15 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package scanIdentities import ( diff --git a/services/services.go b/services/services.go index 7c71ee2ca3e96d2219cd34f4d815ee9320a49233..ecc058f19c8016fef7f79c69e492619aa734fd63 100644 --- a/services/services.go +++ b/services/services.go @@ -1,3 +1,15 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package services import ( @@ -43,14 +55,14 @@ const ( ` queryRenameCategory = ` - mutation RenameCategory ($ca: String!, $nN: String!) { - caRen: renameService(category: $ca, newName: $nN) + mutation RenameCategory ($ca: String!, $sp: String, $nN: String!) { + caRen: renameService(service: CATEGORY, category: $ca, speciality: $sp, newName: $nN) } ` queryRenameSpeciality = ` mutation RenameSpeciality ($ca: String!, $sp: String!, $nN: String!) { - spRen: renameService(category: $ca, speciality: $sp, newName: $nN) + spRen: renameService(service: SPECIALITY, category: $ca, speciality: $sp, newName: $nN) } ` @@ -313,6 +325,8 @@ func endRenCa (name string, temp *template.Template, r *http.Request, w http.Res mk.StartObject() mk.PushString(oldCategory) mk.BuildField("ca") + mk.PushString(speciality) + mk.BuildField("sp") mk.PushString(newCategory) mk.BuildField("nN") mk.BuildObject() diff --git a/signIn/signIn.go b/signIn/signIn.go index 424d1a1851107249eeeefdadc7938be7132cda4e..7a76d4f43f34ca6608814cf135eb84a5756ec98d 100644 --- a/signIn/signIn.go +++ b/signIn/signIn.go @@ -1,3 +1,15 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package credentialsEnter import ( diff --git a/static/static.go b/static/static.go new file mode 100644 index 0000000000000000000000000000000000000000..40f0650585dd120487f5af3cc1aaa53970387980 --- /dev/null +++ b/static/static.go @@ -0,0 +1,42 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +package static + +// Package strMapping implements a mapping between keys and lengthier strings. + +// This package must be imported for its side effects when the content of strMapping resource files is stored in "util/strMapping/static" (file "vars.go", variables "compiler" and "str") + +import ( + + SM "git.duniter.org/gerard94/util/strMapping" + "io" + "io/ioutil" + "strings" + +) + +func linkString (lang string) (io.ReadCloser, bool) { + switch lang { + case "": + return ioutil.NopCloser(strings.NewReader(strEn)), true + case "fr": + return ioutil.NopCloser(strings.NewReader(strFr)), true + default: + return nil, false + } + return nil, false +} + +func init () { + SM.SetLStr("skillsclient", linkString) +} diff --git a/static/vars.go b/static/vars.go new file mode 100644 index 0000000000000000000000000000000000000000..a8ce353b0909436bc79416eeb3fa281432f40f84 --- /dev/null +++ b/static/vars.go @@ -0,0 +1,275 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +package static + +// Package strMapping implements a mapping between keys and longer strings. + +var ( + + strEn = `STRINGS + +Add_Info Additional informations: +AddLoc Add Country / Region +AddSer Add Category / Speciality +BothLbl Both +CaRen Rename Category +CategoryLbl New Category: +CategoryRen Rename Category +221categoryRename Manager: Rename Categories +123citiesRename Manager: Rename Cities +Client Client Version: +CoRen Rename Country +CountryLbl New Country: +CountryRen Rename Country +121countryRename Manager: Rename Countries +CredentialsCreate Create Credentials +311credentialsCreate Manager: Create Credentials +CredentialsReset Reset Credentials +312credentialsReset Manager: Reset Credentials +CredentialsEnter Enter Credentials +CityRen Rename City +CyRen Rename City +dontExistCa Category ^0 doesn't exist in the base +dontExistCo Country ^0 doesn't exist in the base +dontExistId Nickname ^0 doesn't exist in the base +dontExist2Loc Location ^0/^1 doesn't exist in the base +dontExist2Ser Service ^0/^1 doesn't exist in the base +Email Email: +en English +existsId nickname ^0 already exists in the base +exists2Loc Location ^0 / ^1 already exists in the base +exists2Ser Service ^0 / ^1 already exists in the base +ExpiredToken Your session has expired, please sign in again +fr Français +G1_nickname Ğ1 Nickname: +HintLbl Nickname or prefix: +HintPlaceHolder Type the beginning of a nickname +IdentitiesScan Scan Identities +42identitiesScan Scan Identities +IdentitiesSearch Search Services +41identitiesSearch Search Services +IdentityChange Change Identity +32identityChange Manager: Change Identity +43identityChange Change Identity +IdentityRemove Remove Identity +33identityRemove Manager: Remove Identity +idInLoc There are identities in location ^0 / ^1 +idInSer There are identities in service ^0 / ^1 +IdListLbl List of nicknames: +Index Index +index index +inVoidCa Speciality ^0 in void category +inVoidCo Region ^0 in void country +inVoidRg City ^0 in void region +language Choose Language +Locations Locations^0: +LocationsIns Insert Locations +11locationInsert Manager: Insert Locations +LocationRem Remove Locations +13locationRemove Manager: Remove Locations +LockSystem Lock System +34lockSystem Manager: Lock System +LocList Locations List: +LocRem Remove Country / Region +NewCategoryLbl New Category Name: +NewCityLbl New City Name: +NewCountryLbl New Country Name: +newPassLbl New Password: +NewRegionLbl New Region Name: +NewSpecialityLbl New Speciality Name: +NicknameL Nickname^0: +Nicknames Nicknames^0: +nnNull New name is void +No No +OK OK +PassLbl Password^0: +Pickup Can store goods? +Pubkey Ğ1 Public Key^0: +Recorded Your data have been recorded +RegionLbl New Region: +RegionRen Rename Region +122regionRename Manager: Rename Regions +RemDone ^0's form removed +RemNotice Warning: You're about to delete ^0's form +RgRen Rename Region +Searched_services Researched Services: +SeLbl Searched +Select Select: +SerList Services List: +SerRem Remove Category / Speciality +Server Server Version: +21serviceInsert Manager: Insert Services +ServiceRem Remove Services +23serviceRemove Manager: Remove Services +ServicesIns Insert Services +SesuLbl Do you look for supplied or for searched services? +signIn Change User +SpecialityLbl New Speciality: +SpecialityRen Rename Speciality +222specialityRename Manager: Rename Specialities +SpRen Rename Speciality +StringPlaceHolder Type a text +SuLbl Supplied +Supplied_services Supplied Services^0: +SystemLocked The system is locked for everybody but ^0 until at most ^1 +SystemUnlocked The system is unlocked +Tools Tools Version: +Transport Can transport goods? +TypeCategory Type a category +TypeCities Type the cities where you operate in ^0 / ^1 (line by line): +TypeCity Type a city +TypeCountry Type a country +TypeRegion Type a region +TypeSpeciality Type a speciality +UnderConstruction The service is under construction; retry later +UnlockSystem Unlock System +voidCa Void category +voidCo Void country +voidCy Void city +voidNN Void nickname +voidPwd Void password +voidRg Void region +voidSp Void speciality +WrongCredentials Incorrect nickname or password +WrongToken Wrong Token +Yes Yes +` + strFr = `STRINGS + +Add_Info Autres informations: +AddLoc Insérer ce lieu +AddSer Insérer ce service +BothLbl Les deux +CaRen Renommer la catégorie +CategoryLbl Nouvelle catégorie : +CategoryRen Renommer des catégories +221categoryRename Gestionnaire : Renommer des catégories +123citiesRename Gestionnaire : Renommer des villes +Client Version client : +CoRen Renommer le pays +CountryLbl Nouveau pays : +CountryRen Renommer des pays +121countryRename Gestionnaire : Renommer des pays +CredentialsCreate Création d'identifiants +311credentialsCreate Gestionnaire : Création d'identifiants +CredentialsReset Renouvellement d'identifiants +312credentialsReset Gestionnaire : Renouvellement d'identifiants +CredentialsEnter Vérification des identifiants +CityRen Renommer des villes +CyRen Renommer la ville +dontExistCa La catégorie ^0 n'existe pas dans la base +dontExistCo Le pays ^0 n'existe pas dans la base +dontExistId Le pseudo ^0 n'existe pas dans la base +dontExist2Loc Le lieu ^0/^1 n'existe pas dans la base +dontExist2Ser Le service ^0/^1 n'existe pas dans la base +Email Courriel : +en English +existsId Le pseudo ^0 existe déjà dans la base +exists2Loc Le lieu ^0 / ^1 existe déjà dans la base +exists2Ser Le service ^0 / ^1 existe déjà dans la base +ExpiredToken Votre session est terminée, veuillez renseigner à nouveau vos identifiants +fr Français +G1_nickname Pseudo Ğ1 : +HintLbl Début de pseudo : +HintPlaceHolder Entrez un pseudo ou un début de pseudo +IdentitiesScan Parcourir les fiches +42identitiesScan Parcourir les fiches +IdentitiesSearch Recherche de services +41identitiesSearch Recherche de services +IdentityChange Modifier une fiche +32identityChange Gestionnaire : Modifier des fiches +43identityChange Modifier sa fiche +IdentityRemove Supprimer des fiches +33identityRemove Gestionnaire : Supprimer des fiches +idInLoc Il y a des fiches dans ce lieu : ^0 / ^1 +idInSer Il y a des fiches dans ce service : ^0 / ^1 +IdListLbl Liste des pseudos : +Index Menu +index menu +inVoidCa La spécialité ^0 n'a pas de catégorie +inVoidCo Le département ^0 n'a pas de pays +inVoidRg La ville ^0 n'a pas de département +language Choix de la langue +Locations Lieux^0 : +LocationsIns Ajouter des lieux +11locationInsert Gestionnaire : Ajouter des lieux +LocationRem Supprimer des lieux +13locationRemove Gestionnaire : Supprimer des lieux +LockSystem Bloquer le système +34lockSystem Gestionnaire : Bloquer le système +LocList Liste des lieux : +LocRem Supprimer ce lieu +NewCategoryLbl Nouveau nom de la catégorie : +NewCityLbl Nouveau nom de la ville : +NewCountryLbl Nouveau nom du pays : +newPassLbl Nouveau mot de passe : +NewRegionLbl Nouveau nom du département : +NewSpecialityLbl Nouveau nom de la spécialité : +NicknameL Pseudo^0 : +Nicknames Pseudos^0 : +nnNull Le nouveau nom est vide +No Non +OK OK +PassLbl Mot de passe^0 : +Pickup Peut faire dépôt de marchandises ? +Pubkey Clef publique Ğ1^0 : +Recorded Vos données ont été enregistrées +RegionLbl Nouveau département : +RegionRen Renommer des départements +122regionRename Gestionnaire : Renommer des départements +RemDone La fiche de ^0 a été supprimée +RemNotice Attention : Vous êtes sur le point de supprimer la fiche de ^0 +RgRen Renommer le département +Searched_services Services recherchés : +SeLbl Recherchés +Select Sélectionner : +SerList Liste des Services : +SerRem Supprimer le service +Server Version serveur : +21serviceInsert Gestionnaire : Ajouter des services +ServiceRem Supprimer des services +23serviceRemove Gestionnaire : Supprimer des services +ServicesIns Ajouter des services +SesuLbl Êtes-vous intéressés par des services fournis ou recherchés ? +signIn Changer d'utilisateur +SpecialityLbl Nouvelle spécialité : +SpecialityRen Renommer des spécialités +222specialityRename Gestionnaire : Renommer des spécialités +SpRen Renommer la spécialité +StringPlaceHolder Entrez un texte +SuLbl Fournis +Supplied_services Services fournis^0 : +SystemLocked Le système est bloqué pour tous sauf ^0 jusqu'à ^1 au plus tard +SystemUnlocked Le système est débloqué +Tools Version outils : +Transport Peut transporter des marchandises ? +TypeCategory Entrez une catégorie +TypeCities Entrez les villes où vous intervenez dans ^0 / ^1 (ligne par ligne) : +TypeCity Entrez une ville +TypeCountry Entrez un pays +TypeRegion Entrez un département +TypeSpeciality Entrez une spécialité +UnderConstruction Le service est en travaux ; veuillez réessayer plus tard +UnlockSystem Débloquer le système +voidCa Categorie vide +voidCo Pays vide +voidCy Ville vide +voidNN Pseudo vide +voidPwd Mot de passe vide +voidRg Département vide +voidSp Spécialité vide +WrongCredentials Pseudo ou mot de passe incorrect +WrongToken Jeton incorrect +Yes Oui +` +) diff --git a/web/web.go b/web/web.go index 2ada92c1fff97c0650dcc6da54dcf18871830249..080ab3f468437893bf22d3a59d51ba1a9e9f6957 100644 --- a/web/web.go +++ b/web/web.go @@ -1,3 +1,15 @@ +/* +Skills + +Copyright (C) 2023 GérardMeunier + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package web import ( @@ -7,10 +19,12 @@ import ( GS "git.duniter.org/gerard94/skillsclient/gqSender" J "git.duniter.org/gerard94/util/json" M "git.duniter.org/gerard94/util/misc" + R "git.duniter.org/gerard94/util/resources" SM "git.duniter.org/gerard94/util/strMapping" "encoding/base64" "fmt" "net/http" + "os" "html/template" "time" @@ -73,6 +87,10 @@ const ( minNonAdminIndex = "4"; BlockingMaxDuration = 4 * time.Hour + + adminsPass = "skillsclient/adminsPass.txt" + oldAdminsPass = "skillsclient/adminsPass1.txt" + adminsPassMaxSize = 0x3000 ) @@ -115,6 +133,9 @@ var ( onlyUser string = "" onlyUserTimer *time.Timer + + ap = R.FindDir(adminsPass) + oldAp = R.FindDir(oldAdminsPass) ) @@ -221,6 +242,25 @@ func insertAdmins () { for _, id := range credentials { fmt.Println(id.nickname, id.password) } + + fi, err := os.Stat(ap) + M.Assert(err == nil || os.IsNotExist(err), err, 101) + var f *os.File + if err != nil || fi.Size() >= adminsPassMaxSize { + err := os.Remove(oldAp) + M.Assert(err == nil || os.IsNotExist(err), err, 102) + err = os.Rename(ap, oldAp) + M.Assert(err == nil || os.IsNotExist(err), err, 103) + f, err = os.Create(ap) + M.Assert(err == nil, err, 104) + } else { + f, err = os.OpenFile(ap, os.O_APPEND | os.O_WRONLY, 0644) + M.Assert(err == nil, err, 105) + } + defer f.Close() + for _, id := range credentials { + fmt.Fprintln(f, id.nickname, id.password) + } } func IsOnlyUser () bool {