Friday, September 20, 2024 12:11:53 AM
> settings

Customize


Authenticate

> wiki_controller.rb
class WikiController < ApplicationController
  API_ENTRIES = Dir.entries(File.join(Rails.root, "app/views/wiki/api"))
    .reject { |f| [".", ".."].include?(f) }
    .map { |f| f[1..].sub(".html.erb", "") }
    .sort
    .freeze

  CHANGELOG_ENTRIES = Dir.entries(File.join(Rails.root, "app/views/wiki/changelogs"))
    .reject { |f| [".", "..", "template.html.erb"].include?(f) }
    .map { |f| f[1..].sub(".html.erb", "") }
    .sort
    .reverse
    .freeze

  def index
  end

  def commands
    @commands = CommandDetail.all.order(command_category: :asc).to_a.group_by(&:command_category)

    # Sort the commands
    @commands.each do |category, commands|
      @commands[category] = commands.sort_by(&:command_usage)
    end
  end

  def api
    return redirect_to wiki_api_path(function: API_ENTRIES.first) if API_ENTRIES.exclude?(params[:function])

    @function = params[:function]
  end

  def changelog
    return redirect_to wiki_changelog_path(date: CHANGELOG_ENTRIES.first) if CHANGELOG_ENTRIES.exclude?(params[:date])

    @changelog = params[:date]
  end
end
All opinions represented herein are my own
- © 2024 itsthedevman
- build 3c15a1b