Site rearrangement scripting: What's the best venue?

I have been writing a script, driven by a YAML file, for rearranging a Discourse site. This is because I’m planning a pretty massive rearrangement of my largest site to make it easier to navigate, and I’ll never go through with it if I try to drive it through the UI.

My script has zero unit tests, and while I’m a general proponent of unit tests and have been for a long time, I’m not motivated to write any for this script.

The script is really a framework on which to build — not everyone will want the same semantics that I want. In that sense, it’s kind of like some of the migration scripts where you expect that folks will probably modify them to suit.

With those constraints, is this something worth submitting a PR for? Or would folks prefer that I post it as a code block, maybe in #documentation:sysadmin?

I mostly want to help anyone else who is trying to do something similar. Also, the actual functions might help folks know what to do in the rails console.

3 Likes

I have no idea what “site rearrangement” means. Maybe post pieces in Administrative Bulk Operations?

I don’t grok “MSN” but in my case what I am doing includes moving posts between categories, adding tags, reparenting posts, hiding categories, adding redirects… Some of the tasks are covered in Administrative Bulk Actions and some not, but in and case all from a single script.

Currently, in my case, this is 112 actions. I’m not typing that out in a combination of rails c and rake back and forth, potentially several times per hour as I explore different reorganizations of my site with my site leadership.

The question isn’t “how can I accomplish this?” — I’ve already written it, though I intend to continue to improve it (e.g. I’ll probably also have it write a complete, detailed audit log, something it doesn’t do yet but I might want to have before I actually run this for the live site).

The question is: how best to share it? I don’t see anything like it in the scripts/ directory (though maybe I’ve missed something) and I appreciate that PRs should normally come with automated tests (though I don’t know how strongly this applies to the scripts/ directory). At the same time, it’s already over 150 lines and growing, which seems big for sharing by posting here, where it would be vastly bigger than a code box.

OOps. that was “maybe” not “MSN”. :person_shrugging:

I think you post it to github and link to it–either create a topic for it or add it to the admin bulk operations.

2 Likes

Creating it as a standalone GitHub project is the best way forward. Also make sure to create a topic about the tool here on Meta so people can find about it.

4 Likes

Yeah, I definitely want people to be able to find it!

I started it with:

require_relative "../config/environment"

for it to work when placed in the scripts directory. Is there a common pattern for having it live outside the discourse directory? (I don’t see anything in .gitignore like the plugins pattern for checking out things other than plugins inside a checkout.)

If not I can just say “copy it into scripts/” as the install instructions, but just want to know if there’s something I can do to fit in better.

We have a project that uses a setup like:

cd /var/www/discourse/script
git clone https://github.com/user/discourse-config-tool.git
cd ..
bundle exec ruby script/discourse-config-tool/app.rb

Something like this would fit install instructions for your tool.

3 Likes

Thanks! Always makes it easier for others to fit an existing pattern!

I’ll bundle it up and post in #documentation:sysadmin with more concrete information once it’s in place.

2 Likes

Maybe that was the wrong category; it went up for moderation.

Should I have submitted here in #dev instead?

I’ve approved it for you.

3 Likes

Many thanks @Stephen!

For anyone whose search leads them here instead of there in the future:

2 Likes