-
-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server List from JSON #3165
Server List from JSON #3165
Conversation
Not a fan of reading from wiki--anyone can create an account and vandalize that. Could we maintain a file in this repo (or a separate repo) to hold that information? |
You can do it through the wiki, as long as the page has admin-only access. Other sites do this sort of thing. The Battle for Wesnoth does this for their download links when they release updates, and the system works well, especially for maintainers who are not well-versed with command line functions. |
Still, I think most pieces of software with update checks will utilize REST APIs (for example, GET |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the refresh button behave the same as for manually updating spoilers in settings?
- disable it during update process
- change label to
Updating...
during that time
Otherwise there is no way a users knows that something is going on or finished processing.
cockatrice/src/dlg_connect.cpp
Outdated
default: | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looping really necessary here? All it does is increment an index variable, which is used in a switch - wouldn't directly indexing the serverValues
list be nicer?
short nameIndex = 1;
short addressIndex = 5;
short portIndex = 6;
serverName = QString(serverValues.at(nameIndex)).remove(QRegExp("<a[^>]*>")).split("</a>").at(0);
serverAddress = QString(serverValues.at(addressIndex)).remove("<strong>").split("</strong>").at(0);
serverPort = QString(serverValues.at(portIndex)).remove("<strong>").split("</strong>").at(0);
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I wrote this on a whim and once it worked I put it up for review. Looking back, the loop is kind of pointless and I'm sure there's a better way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way I don't really like that we get this list from a displayed source; if someone would change the formatting of the text (e.g. make it italic) the code would also have to be changed. It would be much better imo if we either had a dedicated file for the server list or used an API as @ancestral proposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be fine with having a dedicated file; where would we store it?
That's not working for us I think.
We would have to make all wiki admin-only. You can't do that for certain pages only I think? The wiki page was for pretty presentation purpose, its structure or content might change (like I added the up/down badges recently). The parsing code would need to reflect such changes. Or somebody could easily mess a change up without even noticing and break things for all users. As spoken about in the initial issue, I prefer a github based file, too.
We don't want to do that I guess? 😛 Custom created servers should always be kept. Do we need two lists here then? |
cockatrice/src/dlg_connect.cpp
Outdated
default: | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way I don't really like that we get this list from a displayed source; if someone would change the formatting of the text (e.g. make it italic) the code would also have to be changed. It would be much better imo if we either had a dedicated file for the server list or used an API as @ancestral proposed.
@tooomm Nothing I can do about the sorting issue; If we capitalize the server name on the page, it should work. We added manually and this is how QMaps work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wiki is publicly editable. I think this is a bad idea. We should keep the data file in git and download from there.
@Daenyth As I was trying to say, you would make the page private, editable only by admins or certain people. |
@ancestral Far as I can tell, there is no "private, editable-only-by-admins" option for wiki pages. All pages are editable by any GitHub user who has access to the repo. |
@Nightfirecat It might depend on the wiki software you are running, but you can definitely add user groups in MediaWiki. |
I'm referring to GitHub wiki, since that's where it's currently stored. |
You can limit edits to org members in the github wiki too, but then all server admins can't manage their data anymore on their own as outlined above since they are not involved in development mostly. As well as the other drawbacks which come with using the wiki as source. IMO it's not the best solution here. |
I'd really prefer using git. It has a review process, it's public, and it's reliable. Even if we can lock the one wiki page to org members only. |
You can only lock all wiki as far as I know^^ +1 for git |
Latest Commit: Will now use https://github.com/Cockatrice/cockatrice.github.io/blob/master/public-servers.json instead of the Wiki. This allows us to keep the server details in git, prevent issues with stylistic changes, and better determine the order shown in client. |
|
…lass includes instead of full includes, one NAM
Ok, I've addressed everyone's comments... How's this looking now @Daenyth @ctrlaltca @tooomm ? I've also added an option with this latest push to have a menu option that refreshes the servers. This will be the new default as of the 2.7.0 release (next next release) where we will remove the GUI button. |
Any opinions on a one-time flush of the server list so it re-downloads the public? Or should we leave it as is? I just tested with an older .ini file and refreshed. While it added the new servers, the old ones were left behind (since they were "custom" and were old)... I'd like to flush them all first time through |
Yes, I realized that the old woods server didn't get deleted, too. Another thing I run into, is that refreshing the list kills your selection and jumps to last host used. So if you swapped servers and entered new login details but decide to refresh servers first, all your new input data is lost and the selection jumps back to the last connected server. |
From Gitter:
I have to disagree here. I highly prefer the option within the related dialog instead a separate option in the main app menu. |
@tooomm I love that idea of re-using the "refresh" button from the shortcuts! I'll look into that today or tomorrow. If that's the case and we stick with it, I'll be removing the dialog option as it won't be needed. |
Newest commit: Reverts the menu option, moves the button and uses the refresh icon next to the server list with a tool tip to let you know what it does. On successful run, it will ask the user if they want to clear their old list or not (Sorry @Daenyth :P). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise seems good.
cockatrice/src/window_main.cpp
Outdated
@@ -1205,7 +1227,7 @@ int MainWindow::getNextCustomSetPrefix(QDir dataDir) | |||
|
|||
void MainWindow::actManageSets() | |||
{ | |||
auto *w = new WndSets; | |||
w = new WndSets; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a one-character variable name was okay in this local scope, but since now it's made into a data member of a quite large class it probably should get a more expressive name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
Check #3182 please |
|
||
bool serverFound = false; | ||
for (const auto &iter : savedHostList) { | ||
if (iter.first == serverName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Change this to match by URL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciating the code cleanup with this 👍
Nice work!!
QString serverPort = serverMap["port"].toString(); | ||
|
||
bool serverFound = false; | ||
for (const auto &iter : savedHostList) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be clearer with std::find_if
but this is also fine 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never heard of it, so I'd rather leave it as-is for now. Will look into the standard functions though for future reference!
settings->setValue("chat/mention", chatMention); | ||
} | ||
|
||
void SettingsCache::setChatMentionCompleter(const int _enableMentionCompleter) | ||
{ | ||
chatMentionCompleter = _enableMentionCompleter; | ||
chatMentionCompleter = (bool)_enableMentionCompleter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not static_cast
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clion changed it to be like this. I'm assuming it has something to do with the const functionality and it might need a const_cast
which is dangerous. C style probably avoids this. @ctrlaltca ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The member var chatMentionCompleter
is a boolean, while the _enableMentionCompleter
parameter is an integer. Clion just made the "int to bool" cast explicit; no const involved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dynamic cast then? I thought our style was to not use the c-style paren casts any more in favor of the cpp casts
return false; | ||
} | ||
return true; | ||
return !forbiddenKeys.contains(checkSequence); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I really appreciate everyone going through the multiple rounds of feedback; this is going to be a great feature for our users. Nice work @ZeldaZach @Vafthrudnir @ctrlaltca @Nightfirecat @tooomm :D |
Agreed, great work all, and especially great work @ZeldaZach for implementing! |
@Lachee @dev-id Please keep that updated in case of important changes (as well as the wiki page for public servers). (@Lachee: Also, check your gitter pm's by chance 😉) |
Fixes #2226
This PR will take the servers from the list on
the wikiGitHub Public Servers JSON and import them to the client, thus removing the dependency on hardcoded values.When the user "refreshes the servers", we will re-download the list and clear any server not found on the public list.