Skip to content
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

Site replacement #91

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Site replacement #91

wants to merge 3 commits into from

Conversation

the0d0re9
Copy link

Implementation for #90

@asciimoo
Copy link
Owner

This can be definitely a useful feature with some polishing. First of all, I would make URLs configurable. Also, I wouldn't make it enabled by default.

@the0d0re9
Copy link
Author

URLs are configurable in the source code, and it's behind a environment variable to enable it, didn't want to enable it by default :-)

@asciimoo
Copy link
Owner

var REPLACE_SITES = os.Getenv("REPLACE_SITES") != "false"

It means it is active every case by default except you explicitly specify REPLACE_SITES="false" environment variable, so it is enabled by default.

URLs are configurable in the source code,

It isn't configurable, you have to recompile your code every time you'd want to change it. By configurable I mean a config file for example.

@the0d0re9
Copy link
Author

var REPLACE_SITES = os.Getenv("REPLACE_SITES") != "false"

It means it is active every case by default except you explicitly specify REPLACE_SITES="false" environment variable, so it is enabled by default.

URLs are configurable in the source code,

It isn't configurable, you have to recompile your code every time you'd want to change it. By configurable I mean a config file for example.

Damn that is embarrassing, sorry, I wrote the code last night a bit too early into the morning.

Oh dear, sorry about that. The logic never clicked in my head. Just assumed DEBUG would be disabled by default. My bad, alright. Any specific format you'd want for the configurable URLs? Also are you on Matrix? Tried to look for you in the searx channels but couldn't find you.

I think Morty is an awesome project, and I'm hoping to contribute some more changes I've been running on my instance and playing about with.

@asciimoo
Copy link
Owner

Damn that is embarrassing, sorry, I wrote the code last night a bit too early into the morning.

No need to apologize, we all make mistakes, that's why code review is useful. =)

Any specific format you'd want for the configurable URLs?

It would be good to use an easily editable user-readable format, what about JSON or a simple CSV?

Tried to look for you in the searx channels but couldn't find you.

I'm online both on freenode's and ircnet's #searx channel.

I think Morty is an awesome project, and I'm hoping to contribute some more changes I've been running on my instance and playing about with.

Awesome!

@the0d0re9
Copy link
Author

Added json config support and swapped to using flags rather than environment variables. :-)

@the0d0re9 the0d0re9 force-pushed the site-swap branch 4 times, most recently from a5a9b90 to af8f4e1 Compare July 13, 2020 17:20
@the0d0re9
Copy link
Author

Sorry for the force pushes, git is not kind to mistakes :-(

morty.go Outdated
@@ -991,6 +1004,7 @@ func main() {
version := flag.Bool("version", false, "Show version")
requestTimeout := flag.Uint("timeout", 2, "Request timeout")
socks5 := flag.String("socks5", "", "SOCKS5 proxy")
siteReplace := flag.Bool("replace", false, "Enable experimental site redirection")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a bool switch this could be used to set the path of the json file.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I'd remove the "experimental" word.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the way you want to go we can do that, but I feel like using that as a path to the json file lends itself to being enabled by default. If we set a default people will automatically use it, if we don't nobody will know about it. It's your decision though.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be empty by default

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you think that will cause more people not to use it? I really think that's adding complexity, it's not a well known feature, how will they know sites.json is the site replacement file

@the0d0re9
Copy link
Author

Another consideration to make, should we modify the banner to say some sites have been remapped? Obviously most of the people operating morty wouldn't abuse this maliciously, but it may be worth adding just for clarity to users.

@asciimoo
Copy link
Owner

Another consideration to make, should we modify the banner to say some sites have been remapped? Obviously most of the people operating morty wouldn't abuse this maliciously, but it may be worth adding just for clarity to users.

This is definitely a good idea

@the0d0re9
Copy link
Author

Another consideration to make, should we modify the banner to say some sites have been remapped? Obviously most of the people operating morty wouldn't abuse this maliciously, but it may be worth adding just for clarity to users.

This is definitely a good idea

Any preference on where this message is? or how we show the user that?

@asciimoo
Copy link
Owner

Any preference on where this message is? or how we show the user that?

Probably the best would be to display it on the currently viewed page if there are rewrites. What do you think?

@the0d0re9
Copy link
Author

Any preference on where this message is? or how we show the user that?

Probably the best would be to display it on the currently viewed page if there are rewrites. What do you think?

Works for me, this will require quite a bit of a refactor as the current layout of the codebase isn't super suitable for that sort of thing, is that alright?

@asciimoo
Copy link
Owner

I have some local changes, let me push it, probably it will make the implementation easier.

@asciimoo
Copy link
Owner

Pushed, take a look at the new body extension, it uses go templates, which probably makes it easier to add new values to it.

@the0d0re9
Copy link
Author

That does make it much easier, thank you :-)

@asciimoo
Copy link
Owner

No problem. The new layout can be buggy with sites using fancy css, so it needs a bit more refinement, but we can do it later. I tested it with quite a few sites and it works well so far.

@the0d0re9
Copy link
Author

No problem. The new layout can be buggy with sites using fancy css, so it needs a bit more refinement, but we can do it later. I tested it with quite a few sites and it works well so far.

Still tracking this, just had some personal issues that mean I've been unable to code for the last few days

@asciimoo
Copy link
Owner

Still tracking this, just had some personal issues that mean I've been unable to code for the last few days

Thanks, no worries, take your time. =]

@mutageneral
Copy link

@the0d0re9 so how is it going? no pressure, just a friendly reminder this existed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants