tosher / Mediawiker

A plugin for Sublime Text editor that adds possibility to use it as Wiki Editor on MediaWiki-based sites like Wikipedia and many other.
Other
137 stars 27 forks source link

[v3.4.9] Observations, Issues, suggestions etc #134

Closed TriMoon closed 5 years ago

TriMoon commented 6 years ago

Hi it's been a while since i used this extension, and just started to use it again in ST3. Below are some observations from a fresh user point of view:

  1. There is no default for wikia (Now FANDOM) type wikis, had to go search to find how to configure it.
  2. All Settings should be able to be overridden per wiki in user settings.
    1. These should also be able to be set in a project file, which overrides user settings...
    2. While inside a settings node the keys should be without the "mediawiker_" prefix for aesthetics/readability and space ...
    3. Example: Favorites are saved inside top settings-node. Intuitive use: This should become a subkey inside the wiki-specific settings.
  3. Sometimes opening pages, eg. from favorites, does not open the page but gives an error in console TypeError exception for get_page: unorderable types: int() > NoneType() must be a time-out?
  4. Pages history does not get populated, or is unclear what it is supposed to be for... Intuitive use: While working on a wiki, it should list recent pages opened.
  5. Syntax highlighting
    1. Does not properly recognize parser functions, eg: {{#if:..}} etc are treated as templates and get that kind of popup which is wrong...
      1. HTML with CSS styles used as arguments to parser functions don't get properly highlighted. For sample data see the source of Template:Progress.
  6. Preview
    1. does not take into account the namespace of the page being previewed. This causes links to templates in Template: namespace to be wrong. -> Only happens for locally opened pages, works ok when page is opened from wiki...
    2. Still trying to get it render like online version, background etc is not good...
  7. Maybe more will add as i notice :wink:
tosher commented 6 years ago
  1. Example for quake.wikia.com:
    "mediawiker_site": 
    {
    "quake.wikia.com":
    {
        "domain": "",
        "host": "quake.wikia.com",
        "https": false,
        "pagepath": "/wiki/",
        "password": "mypassword",
        "path": "/",
        "username": "my-username-at-wikia.com"
    }
    }

    Username and password - from wikia site, not from facebook or google.

Without credential defining, you can use cookies from browser:

  "authorization_type": "cookies",
  "cookies_browser": "firefox"
  1. Needs real use-cases and then any option can be moved to per-wiki-settings. i. I think, it's an additional redundant complication for text editing. But... use cases are welcome :) ii. mediawiker_ - maybe in future versions iii. Favorites - No user action is required with this settings, it's just a storage.
  2. Example (if public)?
  3. It's recent pages published.
  4. Needs examples as blocks of text or as lines from some page.
  5. Page Preview command uses wiki api to generate page.
  6. You're welcome! :)
TriMoon commented 6 years ago

quick reply @tosher ,

  1. I'm working with project files inside ST3 to organize my editing of many things.
    1. Use case as mentioned just above, i use project files for different task, and in this case i use one project called Wiki in which i edit pages on different wiki's, so settings inside the project file will help to keep settings per wiki in it...
    2. This is just a hint to make the settings inside user-settings and project settings be more readable while under a node(object) named mediawiker :wink:
    3. Same as above, will keep things together inside 1 object/node.
  2. It happens with all pages, trying again succeeds without error...
  3. Then it should be renamed because current name makes a user get wrong idea of functionality...
  4. See the link i gave, it has code and text :wink:
  5. The preview functionality needs more improvement as it is sometimes required to add more as head links. Eg. Article needs to be inside a nested div inside a body with a certain class etc. to render properly using the CSS from the API call "/load.php?..." I would suggest a per-wiki setting to configure multiple files, 1 pre-API text and 1 post-API text., to generate the preview output. A single setting as-is-now is just not enough because it only allows to add to head... Oh and these two files don't need to be parsed for special variables, their content just need to be inserted before and after the API call to render the wiki-text... (makes it easier on you) I currently use 3-4 elements in this settings array, 2 of them are to load local (css+js) files in which i manipulate the html of the preview page to load other css/js files and add extra elements etc...
  6. I really appriciate the work you do :wink:
tosher commented 6 years ago

2.iii. I think, multiple level nesting with normalized data - good for inner storage, but for user settings - not. It's hard to understand and support. Only really special settings must be inside per-wiki-options. Or it must be optional. I'll think about it :)

  1. Maybe..., but it's an editor, not a viewer :) Maybe, I'll add the ability to save all pages there, as an option.
  2. Some fixes will be in the next version. Html&Css with multiline args values, with comments inside, are not supported now.
  3. Please, suggest your version of settings. But without external files. With workable for classic wiki site, default options.
  4. Thank you! :)
tosher commented 6 years ago
  1. https://github.com/tosher/Mediawiker/releases/tag/v3.4.10
TriMoon commented 6 years ago
1. https://github.com/tosher/Mediawiker/releases/tag/v3.4.10

No idea what really changed because the syntax highlighting still looks same, maybe try adding support for ParserFunctions+StringFunctions, eg: {{#xxx:..}}

  1. I'm still improving my script, the current output looks like this. I still can't find the spot where mw is initially populated to pull-in the rest the page needs. That's why the tabber output is still not shown as tabs as it should. Still not perfect :wink: The setting i'm using now looks like this to pull-in my own scripts to manipulate the page: Note im using a local webserver for this purpose, but you could also use a local file next to the generated preview.html
tosher commented 6 years ago

Before

default

After

default

tosher commented 6 years ago
  1. It's your current settings, right? It looks like a self-sufficient :) But I'm asked about "what needs to change" and your version of the settings for it :)
TriMoon commented 6 years ago

About the before and after; I really didn't notice, It is so subtile, but looks better as was :wink: Supporting those function calls would have made a bigger impact :wink:

@tosher 2.iii. I think, multiple level nesting with normalized data - good for inner storage, but for user settings - not. It's hard to understand and support. Only really special settings must be inside per-wiki-options. Or it must be optional. I'll think about it :)

Could you at least start with allowing the settings to be put inside project files? That way we can keep the settings inside a central config per project.

It's your current settings, right? It looks like a self-sufficient :) But I'm asked about "what needs to change" and your version of the settings for it :)

As you can notice the script changes a lot of your default output, to make it look good for wikia. Maybe you could make your default output use the layout and tag-settings it creates?

Oh ps: Your extension should automatically use system-proxy settings when they are available in the environment....

TriMoon commented 6 years ago

More Project based improvement:

tosher commented 6 years ago

Maybe you could make your default output use the layout and tag-settings it creates?

It can be a default for concrete wikia site, not for all. The plugin doesn't have the setting for all sites. We can add an example into project's wiki if you want.

TriMoon commented 6 years ago

Maybe you could make your default output use the layout and tag-settings it creates?

It can be a default for concrete wikia site, not for all. The plugin doesn't have the setting for all sites. We can add an example into project's wiki if you want.

That would be a nice thing if it's finished, but no idea when that will be yet. The script i crafted is setup to allow for user settings, but the layout is for all wikia that uses oasis-skin.

One thing you could add right away now in your extension is the title tag, then i could grab that in my script to display the page name :wink:

tosher commented 6 years ago

Done. https://github.com/tosher/Mediawiker/releases/tag/v3.4.12

TriMoon commented 6 years ago

lol i meant the actual <title>pagename</title> tag inside the head but ill see how to use the var... :rofl:

Just tested but using the below gives a blank <title></title>

"<title>{{ title }}</title>"
tosher commented 6 years ago
"preview_custom_head": [
    "<title>{{ title }}</title>", 
    "<meta charset=\"UTF-8\"/>",
    "<link rel=\"stylesheet\" href=\"{{ http }}://{{ host }}{{ path }}load.php?debug=false&amp;lang={{ lang }}&amp;modules=site&amp;only=styles&amp;skin=vector\"/>",
    "<link rel=\"stylesheet\" href=\"{{ http }}://{{ host }}{{ path }}load.php?debug=false&amp;lang={{ lang }}&amp;modules={{ geshi_css }}ext.visualEditor.viewPageTarget.noscript|mediawiki.legacy.commonPrint,shared|mediawiki.sectionAnchor|mediawiki.skinning.interface|mediawiki.ui.button|skins.vector.styles&amp;only=styles&amp;skin=vector&amp;*\" />"
 ]

With default settings works fine for me.

TriMoon commented 6 years ago

No idea why the title didn't work 2 days ago, but seems to be self-fixed in mean time :+1: Must be browser updates...(I'm using Firefox Nightly)

tosher commented 6 years ago

I'm using Daily :) (i know about builds)

TriMoon commented 6 years ago

Could you enhance the popups that are displayed for the parser functions so that it includes a link to open the documentation in the browser?

Here are links to respective pages on mediawiki website, that are most used:

  1. mw:ParserFunctions
  2. mw:Magic_words
  3. mw:StringFunctions
  4. mw:Variables

It would be super if the page opened would automatically scroll to the respective section on that page using the "#"-hash parameter on the link :wink:

TriMoon commented 6 years ago

oh PS: it would be really appreciated if parser-functions and magic-words would be displayed in different colors from template calls by the syntax-highlighting...

TriMoon commented 6 years ago

Just FYI: I removed the old-gist and created a new gist with:

  1. Mediawiker.sublime-settings Config i use at moment with anonymized parts.
  2. mediawiker_preview_fix.js The actual functionality that changes the preview page, using variables set in 3. (Candidate for inclusion in your extension when ready)
  3. mediawiker_preview_script.js Configuration file that will set variables for and call the function from 2. like
    mediawikerFixPreview(
    '<remote base url>'
    ,'<local base url>' // Can be 'File://<local absolute path>'
    )
  4. mediawiker_preview_style.css CSS-file that is pulled in by 2.

This will make it easier for others to follow/use what i use, and for me to update parts of it to improve things in due time. Keep on coding :+1: :rofl:

tosher commented 6 years ago

Testing..

TriMoon commented 6 years ago

Hmm after 2nd though it might be better to have the project settings be applied after the global mediawiker settings but before the user settings. The user settings should always be the highest priority, so the user in question can always override to its own taste... Especially in case of username and password, which normally won't be in project file settings but you understand the subtle diff in priority :wink:

I'm excited about what is to come :+1:

tosher commented 6 years ago

List is consists of your quotes! :)

In Sublime text projects settings always has a higher priority (it's like a tab's settings) - i think it's a correct way.

As example - many sites in user settings, but one site in separated project.

tosher commented 6 years ago

https://github.com/tosher/Mediawiker/releases/tag/v3.5.0

TriMoon commented 6 years ago

I just checked but:

  1. Usersettings are not automatically converted, i did now by hand...
  2. Not sure what exactly broke but there are no popups anymore at all. Eg. Mediawiker menu (CTRL+SHIFT+F1) and when you hold mouse over text. you get many error messages in console log.
  3. About the project settings text in your changelog: "Project settings support (overrides user settings)", that last part (...) should be removed to make it become correct, because user settings should override the project settings which override default settings :wink:
    • The priority is the default sublime priority for project settings (Am i right?)
  4. About Project settings functionality:
    • Are your settings single separate keys in the project settings file or are they (As customary) under a "mediawiker" object? eg: xxxx.sublime-project
      {
      "mediawiker.category_root": "Category:Templates"
      }

      Instead of the usually used form in project settings:

      {
      "mediawiker": {
      "category_root": "Category:Templates"
      }
      }

      I would think most will prefer the later so they can copy&paste from one settings file to another and it will also ease your parsing of settings as they use same names and logic. You just need to grab the "mediawiker" object from the project file...

tosher commented 6 years ago
  1. Converting fires at the start or on the first call of any setting.
  2. Works for me, detailes needed
  3. Plugin default settings => Plugin user settings => Project settings. Project as extended way for work and it extends plugin's settings.
  4. "mediawiker.category_root": "Category:Templates". Prefixed settings in projects - is a standard way, as I know.
tosher commented 6 years ago

Question, just interesting.. Why not to use one variable per line (just for readability) instead of

{{#vardefine:progress-val | {{{1 | {{{val | {{#var:progress-val|}} }}} }}} 
}}{{#nextdefine|..
}}...

If needs no-breakable line, you can use a <span style="white-space: nowrap">. It can be in separated template like {{nobr}}.

TriMoon commented 6 years ago

Question, just interesting.. Why not to use one variable per line (just for readability) instead of

{{#vardefine:progress-val | {{{1 | {{{val | {{#var:progress-val|}} }}} }}} 
}}{{#nextdefine|..
}}...

If needs no-breakable line, you can use a <span style="white-space: nowrap">. It can be in separated template like {{nobr}}.

The reason for that kind of coding is because templates include newlines in their output if you don't do it this way :wink: it's like:

<div>blabla</div>
<div>blabla</div>

versus:

<div>blabla</div
><div>blabla</div>

For only text displayed you could use the nowrap, but when you generate html extra newlines get converted to <p></p> etc by mediawiki parser, which mess up the generated html.

TriMoon commented 6 years ago
2. Works for me, detailes needed

At this moment when i open my Wiki-Project in ST3, without having any remote wiki page open.

3. Plugin default settings => Plugin user settings => Project settings. Project as extended way for work and it extends plugin's settings.

This should become Plugin default settings => Project settings => Plugin user settings.

4. `"mediawiker.category_root": "Category:Templates"`. Prefixed settings in projects - is a standard way, as I know.

Yes if the plugin has only a very few or single setting that is true, but with a plugin like yours that has many options the otherway is standard. Imagine if eslint (for example) would do what you did.... :wink:

TriMoon commented 6 years ago

update: Seems the no host error above is caused by my own project config, where i used the object notation version instead of your current mediawiker. dot notation....I will try that part later...

update2: Still same with this kind of project settings file

{
    "folders": [
        {   "name": "Other wikia related"
            ,"path": "Wikia"
            }
        ,{  "name": "Trainstation"
            ,"path": "trainstation.wikia"
            }
        ]
    ,"syntax_override": {
        "\\.(mediawiki|wiki)$": ["Mediawiker","MediawikiNG"]
        }
    ,"mediawiker.site": {
            "Trainstation wiki": {
                "username": "*****"
                ,"password": "*****"
                ,"host": "trainstation.wikia.com"
                ,"pagepath": "/wiki/"
                ,"path": "/"
                ,"authorization_type": "login"
                ,"https": true
                ,"is_ssl_cert_verify": true
                ,"is_wikia": true
                ,"preview_custom_head": [
                    "<meta charset=\"UTF-8\"/>"
                    ,"<title>{{ title }}</title>"
                    ,"<script src=\"http://localhost/Wiki/Wikia/mediawiker_preview_fix.js\"></script>"
                    ,"<script src=\"http://localhost/Wiki/trainstation.wikia/mediawiker_preview_script.js\"></script>"
                    ]
                }
            }
}
tosher commented 6 years ago

It's an incorrect project file structure, needs:

{
        "build_systems": [...],
        "folders": [...],
    "settings":
    {
             "mediawiker.site": {...}
        }
}
tosher commented 6 years ago
Error loading scope:source.tsql: Unable to find syntax file for scope source.tsql in Packages/Mediawiker/MediawikiNG.sublime-syntax

Your ST's installation hasn't syntax for tsql. Not error - just message from ST.

Warning: Page has en unclosed element of type Div at position 7177, force closing at 7181..
Warning: Page has en unclosed element of type Div at position 8007, force closing at 8011..

Messages from the plugin's parser - object doesn't has a close-tag or it maybe a parsing error. It's ok for hard pages like yours :) ... and it can brake the popups.

TriMoon commented 6 years ago

After putting your settings in my project file like you showed, the popups started working again and i could load remote wiki pages, but...

It's an incorrect project file structure, needs:


{
        "build_systems": [...],
        "folders": [...],
  "settings":
  {
             "mediawiker.site": {...}
        }
}

You are using the settings object-key of sublime-text self, the note makes it clear that the "settings" object-key is refering to sublime text own settings. Note that only settings in the category Editor Settings may be controlled by a project.

Therefor you should use your own plugins name here instead of "settings" used in that example. By doing so you separate your plugins settings from sublime text self and other plugins so they won't interfere with each other, plus you won't need your dot notation anymore either... example:

{
    "build_systems": [...],
    "folders": [...],
    "settings": { settings for SublimeText },
    "syntax_override": { settings for project specific syntax plugin },
    "mediawiker":
    {
        "site": {...}
    }
}
Error loading scope:source.tsql: Unable to find syntax file for scope source.tsql in Packages/Mediawiker/MediawikiNG.sublime-syntax

Your ST's installation hasn't syntax for tsql. Not error - just message from ST.

Exactly it comes from MediawikiNG.sublime-syntax and starts with Error loading because Mediawiker does not include that file but somehow depends on it. Lines starting with Warning can be harmless but those that start with Error are errors and should be fixed. Just like Javascript errors they make things break. Maybe that's why the other errors...

tosher commented 5 years ago

Another no-brake way, without visually breaking tags:

{{blabla}}<!--
-->{{blabla}}

Just empty comment.

TriMoon commented 5 years ago

Another no-brake way, without visually breaking tags:

{{blabla}}<!--
-->{{blabla}}

Just empty comment.

The whole point of coding like i do is to prevent unwanted output from the template, you just make it output even more unwanted stuff if you do it like that. :wink: Maybe you should look into options to hand-over the syntax highlighting to other highlighters. That will be better for your workload and highlighting issues with any languages people might be using.

Anyway thanks for your work so far, i have stopped editing wiki pages again for some time and moved over to other stuff, but i'm sure i will be needing this project again when i edit wiki's in future :+1: