FANDOM


This is the talk page for discussing improvements to the View Source page.

Polish Localization

In order not to editing conflict:

        pl: {
            viewSource: 'Tekst źródłowy',
            viewArticle: 'Pokaż artykuł'
        }
Vuh17:02, Tuesday, 15 Jan 2013 (UTC+1)@fandom

Undefined

I am not sure if this is known, but sometimes the words 'undefined' are included within a link (Example). This is only for links that are not changed from their original text with a pipe. ElectricCricket 05:03, March 29, 2013 (UTC)

This code is due for a complete rewrite. That particular problem should be gone in the next version. But I'm always looking for people to put my code through its paces. If you're interested, I can notify when the next version is ready! --  pecoes  05:24, March 29, 2013 (UTC) 

I am not interested, but thank you the offer. :-) However, I do have a suggestion which is something more aesthetic than technical; how about making the source-code and source-toc ID's styles match that of the wiki's (that the script is being used on at that time) WikiaArticle pre class? It would make the View Source blend in more with the wiki's overall theme (more than, for example, the currently white-for-all-wiki's View Source backgorund on a darker themed wiki). ElectricCricket 19:36, March 30, 2013 (UTC)

Trying to make something that should work everywhere blend with the host wiki, is usually a lot more hassle than it's worth. I'm speaking from somewhat painful past experience here.
I also think it's more important that the View Source feature is as consistent as possible across wikis. --  pecoes  19:58, March 30, 2013 (UTC) 

I'm also seeing this problem with "undefined" appearing after links. -452 18:15, May 4, 2013 (UTC)

Feature Suggestions

On that note above, I have some feature suggestions myself actually.

  • Automatically hide the siderail when viewing source and expand the content area to full width.
  • Add a thin toolbar above the source code div for user display options. Here's a couple ideas for what could go in that toolbar:
    • Select All button: click to highlight all source code, handy for copy/pasting into a text editor. (I frequently copy code into Notepad++ to get syntax highlighting on JS/CSS/HTML while editing, as well as doing regex replaces. In the Wikia editor, I can just CTRL+A -> CTRL+C the textarea in source mode, but for the View Source script you can't really do that. So a button to quickly highlight all the source code would be nice.)
    • Checkbox to toggle "automatically open all links in a new tab" — it can be frustrating to left-click on a link and have your browser take you away from the source code that you're viewing. (Right-click -> open link in new tab still works of course.)
    • Checkbox to toggle word wrap (sometimes I like word wrap on, sometimes I don't, being able to switch between these is a nice option)
  • Consider tweaking the default link styling. I appreciate that you've made the links unobtrusive with a faint border-bottom, but I can't really see them at all. More of a balance could be struck here.
  • Move the "View source" link out of the edit button dropdown (or maybe have a user option to mount it to different places in the user interface). I don't like it there because it's not actually a "link" in the sense that it takes you to another webpage like all the other links in the dropdown menu. Also, it takes a while to get to. In terms of speed, it would be faster to just click the edit button and view the source code in the editor itself.
    • My personal preference would be to click on the article title (<h1> tag) itself to view the source code.

I've been using my own version of View Source in my user scripts for a few months (code at the bottom of this page) which has some of these features built-in already, so feel free to test it out to demo some of these feature suggestions to get a feel for them in use. My version is very lightweight compared to View Source, so I don't wish to continue working on it. Ideally, I would be using your View Source, if it had the features I wanted :) 20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 18:48 UTC, Saturday, 30 March 2013

I'll go through the points:
Automatically hide the siderail when viewing source and expand the content area to full width.
Lunarity's HideRail can do that much better, I think. Personally I'm fine with the content area constraint. If you want the rail to collapse you're much better off using both tools in conjunction.
Select All button: click to highlight all source code, handy for copy/pasting into a text editor. (I frequently copy code into Notepad++ to get syntax highlighting on JS/CSS/HTML while editing, as well as doing regex replaces.
Will do.
Checkbox to toggle "automatically open all links in a new tab" — it can be frustrating to left-click on a link and have your browser take you away from the source code that you're viewing. (Right-click -> open link in new tab still works of course.)
The right-click -> open link in new tab solution is superior, I think. (Though ctrl+click is even better ;)
(Having said that. I've been toying with the idea of loading the source of templates into the same page...)
Checkbox to toggle word wrap (sometimes I like word wrap on, sometimes I don't, being able to switch between these is a nice option)
Hm. I'll have to think about that one... How would that be useful?
Consider tweaking the default link styling. I appreciate that you've made the links unobtrusive with a faint border-bottom, but I can't really see them at all. More of a balance could be struck here.
Will do.
Move the "View source" link out of the edit button dropdown (or maybe have a user option to mount it to different places in the user interface). I don't like it there because it's not actually a "link" in the sense that it takes you to another webpage like all the other links in the dropdown menu. Also, it takes a while to get to. In terms of speed, it would be faster to just click the edit button and view the source code in the editor itself. My personal preference would be to click on the article title (<h1> tag) itself to view the source code.
Oooh. Using the <h#> tag(s) is a really good idea. Thanks a lot! :) --  pecoes  19:20, March 30, 2013 (UTC) 
I've been toying with the idea of loading the source of templates into the same page...
That sounds like a great idea! I could very easily see that being a great way to navigate through templates in source code. The content area could function like a slider of source code divs. So if there's a ton of nested templates, you could keep clicking to navigate down through the nested templates and each time a new "slide" would animate into place containing the source code for that template. And you could have breadcrumb navigation above the content area:
Page > Template > Template inside of template > etc.
You could use the breadcrumbs to navigate backwards through the nest.
Also there should be some mechanism for visiting those pages in the nest. For example, if I actually want to edit the "Template inside of template" page, I need a way to navigate to that wiki page (not just pull up the "slide" of source code) — maybe each slide could have a "visit this page" link at the top or something.
20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 20:55 UTC, Saturday, 30 March 2013
Breadcrumbs wouldn't work, I'm afraid. Simply because page and template titles can get rather long. I probably need an object browser of sorts.
Something like this:
Page [view] [source] [edit]
  • Sections [collapse]
    • Section title [collapse]
      • Templates [collapse]
        • Template Title [view] [source] [edit]
      • Images [expand]
      • Links [expand]
    • Section title [expand]
  • Templates [expand]
  • Images [expand]
  • Links [expand]
But that won't happen until the version after the next version :)
 pecoes  21:18, March 30, 2013 (UTC) 
An object browser would also be lot, lot harder to make :P. I also don't really like them that much, but that's just me. If title length is the only major concern with breadcrumbs, just truncate the titles with ... and show the full title on hover. 20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 22:20 UTC, Saturday, 30 March 2013
Yes, it would be more work. A lot more probably. It would surely be a good idea to work incrementally towards it and start with something more simpler. Now that I take a second look at the sketch above, I don't like it much either btw. It's a little too complicated without providing much of a bird's eye perspective. But it's only a first sketch...
But all of this is a bit speculative at this point anyway. First I got to finish the syntaxhighlighter stop playing Borderlands2 :D --  pecoes  22:42, March 30, 2013 (UTC) 

The slash symbol is gone!

Today I was testing some new templates. I finished one template and uses the view source function to read the source code, and then I copied it without noticing that:

|<div style="background:{{港島綫色彩}}">{{stndot}}<div>

THE SLASH SYMBOL IS GONE!

And then the other templates I made showed the "retrieved from" thing, until I realized that there is an error on your code and fixed the templates!

The Lightning Pencil 12:48, December 29, 2014 (UTC)

Suggestion

At the moment, the language in the button is equal to the wiki's language (wgContentLanguage). Wouldn't it be better if the language would be equal to the user's language (wgUserLanguage)? -- DarkBarbarian.png Barbar (talk) 17:07, June 13, 2017 (UTC)

Doesn't Appear

I've added the script earlier, but why did it disappear now? ( ͡| ͜' ͡| )⌐╦╦═─ ̿'̿'\̵͇̿̿\з-( ͠| ͟' ͡| )-ε/̵͇̿̿/'̿̿ ̿ ̿ (| ਊ |)▄︻̷̿┻̿═━一 12:54, July 11, 2017 (UTC)

Suggestions

Hello. I would like to add a few suggestions to this script. I like it, but it needs improvements:

  • It is nice that you added a module that contains links leading to sections in the right rail. However, there should be a heading on the top of the module called "Sections" or something like that. Not really something important, though.
  • I'd suggest adding a button that copies the source of a page. It would be very useful for people who use copying as a method to modify a different page.
  • The View Source button should be completely hidden in uncreated articles.
  • The View Source button doesn't work in system messages (MediaWiki: pages). Please fix that.
  • The View Source button doesn't work in older revisions of a page. Please fix that.

~Signed JustLeafy ( ͡| ͜' ͡| ) | USER WALL | 18:03, January 24, 2018 (UTC)

Comments/Thread Posts

Could you guys add a capability that you can use it on Article Comments/Thread Posts? THX! -ThePokegeek5000 02:37, November 20, 2018 (UTC)

Bugs

I've noticed three bugs with this script.

  1. {{raw:w:<template>}} links to [[Template:raw:w:<template>]] instead of [[w:<template>]].
  2. It attempts to show the wikitext contained in AddRailModule, which looks very weird.
  3. {{/<template>}} links to [[Template:/<template>]] instead of [[<pagename>/<template>]]

If you could fix these that'd be great! Patrik 16:27, November 28, 2018 (UTC)

Community content is available under CC-BY-SA unless otherwise noted.

Fandom may earn an affiliate commission on sales made from links on this page.

Stream the best stories.

Fandom may earn an affiliate commission on sales made from links on this page.

Get Disney+