# Site-herschikking scripting: Wat is de beste locatie?

**URL:** https://meta.discourse.org/t/site-rearrangement-scripting-whats-the-best-venue/241892
**Category:** Development
**Created:** [14 oktober 2022 om 01:50 UTC](https://meta.discourse.org/t/site-rearrangement-scripting-whats-the-best-venue/241892 "2022-10-14T01:50:16Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![mcdanlj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcdanlj/32/131829_2.png) [@mcdanlj](https://meta.discourse.org/u/mcdanlj)
#### Post date: [14 oktober 2022 om 01:50 UTC](https://meta.discourse.org/t/site-rearrangement-scripting-whats-the-best-venue/241892/1 "2022-10-14T01:50:16Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [14 oktober 2022 om 12:03 UTC](https://meta.discourse.org/t/site-rearrangement-scripting-whats-the-best-venue/241892/2 "2022-10-14T12:03:22Z")

</div>

I have no idea what “site rearrangement” means. Maybe post pieces in [Administrative Bulk Operations](https://meta.discourse.org/t/administrative-bulk-operations/118349)?

---

<div class="post-metadata">

### Author: ![mcdanlj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcdanlj/32/131829_2.png) [@mcdanlj](https://meta.discourse.org/u/mcdanlj)
#### Post date: [14 oktober 2022 om 13:00 UTC](https://meta.discourse.org/t/site-rearrangement-scripting-whats-the-best-venue/241892/3 "2022-10-14T13:00:40Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [14 oktober 2022 om 13:58 UTC](https://meta.discourse.org/t/site-rearrangement-scripting-whats-the-best-venue/241892/4 "2022-10-14T13:58:40Z")

</div>

> [@mcdanlj](#):
>
> I don’t grok “MSN” but

OOps. that was “maybe” not “MSN”. 🤷

> [@mcdanlj](#):
>
> The question is: **how best to share it?**

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.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [14 oktober 2022 om 15:04 UTC](https://meta.discourse.org/t/site-rearrangement-scripting-whats-the-best-venue/241892/5 "2022-10-14T15:04:11Z")

</div>

> [@mcdanlj](#):
>
> The question is: **how best to share it?**

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.

---

<div class="post-metadata">

### Author: ![mcdanlj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcdanlj/32/131829_2.png) [@mcdanlj](https://meta.discourse.org/u/mcdanlj)
#### Post date: [14 oktober 2022 om 16:52 UTC](https://meta.discourse.org/t/site-rearrangement-scripting-whats-the-best-venue/241892/6 "2022-10-14T16:52:42Z")

</div>

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

I started it with:

```ruby
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.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [14 oktober 2022 om 17:09 UTC](https://meta.discourse.org/t/site-rearrangement-scripting-whats-the-best-venue/241892/7 "2022-10-14T17:09:06Z")

</div>

We have a project that uses a setup like:

```plaintext
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.

---

<div class="post-metadata">

### Author: ![mcdanlj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcdanlj/32/131829_2.png) [@mcdanlj](https://meta.discourse.org/u/mcdanlj)
#### Post date: [14 oktober 2022 om 17:33 UTC](https://meta.discourse.org/t/site-rearrangement-scripting-whats-the-best-venue/241892/8 "2022-10-14T17:33:55Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mcdanlj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcdanlj/32/131829_2.png) [@mcdanlj](https://meta.discourse.org/u/mcdanlj)
#### Post date: [15 oktober 2022 om 02:21 UTC](https://meta.discourse.org/t/site-rearrangement-scripting-whats-the-best-venue/241892/9 "2022-10-15T02:21:10Z")

</div>

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

Should I have submitted here in #Development instead?

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [15 oktober 2022 om 03:06 UTC](https://meta.discourse.org/t/site-rearrangement-scripting-whats-the-best-venue/241892/10 "2022-10-15T03:06:01Z")

</div>

I’ve approved it for you.

---

<div class="post-metadata">

### Author: ![mcdanlj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcdanlj/32/131829_2.png) [@mcdanlj](https://meta.discourse.org/u/mcdanlj)
#### Post date: [15 oktober 2022 om 11:38 UTC](https://meta.discourse.org/t/site-rearrangement-scripting-whats-the-best-venue/241892/11 "2022-10-15T11:38:10Z")

</div>

Many thanks @Stephen!

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

> [@Script framework to rearrange topics and categories](https://meta.discourse.org/t/script-framework-to-rearrange-topics-and-categories/241964):
>
> In order to script rearranging a large Discourse with working with my site leadership, I wrote a simple framework for packaging up a bunch of ruby scriptlets to be driven from a YAML configuration file. This way, I can restore a backup on a staging site, run my script, get feedback, change a few lines of YAML, restore the backup, run the script with new configuration, and repeat until satisfied. I have almost 600 lines of configuration for my site, and doing that by manual manipulation through …
