[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7863":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":16,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":16,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":19,"hasPages":21,"topics":22,"createdAt":10,"pushedAt":10,"updatedAt":23,"readmeContent":24,"aiSummary":25,"trendingCount":15,"starSnapshotCount":15,"syncStatus":26,"lastSyncTime":27,"discoverSource":28},7863,"high_voltage","thoughtbot\u002Fhigh_voltage","thoughtbot","Easily include static pages in your Rails app.","http:\u002F\u002Fthoughtbot.github.io\u002Fhigh_voltage",null,"Ruby",3241,149,55,0,1,59.13,"MIT License",false,"main",true,[],"2026-06-12 04:00:36","# High Voltage [![Build Status](https:\u002F\u002Fgithub.com\u002Fthoughtbot\u002Fhigh_voltage\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg?branch=main)](https:\u002F\u002Fgithub.com\u002Fthoughtbot\u002Fhigh_voltage\u002Factions) [![Reviewed by Hound](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FReviewed_by-Hound-8E64B0.svg)](https:\u002F\u002Fhoundci.com)\n\n> [!NOTE]\n> `high_voltage` is in maintenance-mode. We’re not actively adding new features,\nbut we’ll fix bugs and keep it up to date, and compatible with the latest Ruby\nand Rails versions.\n\nRails engine for static pages.\n\n... but be careful. [Danger!](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=R-FxmoVM7X4)\n\n## Static pages?\n\nYeah, like \"About us\", \"Directions\", marketing pages, etc.\n\n## Installation\n\nThere are two ways to install High Voltage.\n\nYou can run:\n\n    $ gem install high_voltage\n\nOr you can include in your Gemfile:\n\n```ruby\ngem 'high_voltage', '~> 5.0.0'\n```\n\n## Usage\n\nWrite your static pages and put them in the RAILS_ROOT\u002Fapp\u002Fviews\u002Fpages directory.\n\n    $ mkdir app\u002Fviews\u002Fpages\n    $ touch app\u002Fviews\u002Fpages\u002Fabout.html.erb\n\nAfter putting something interesting there, you can link to it from anywhere in your app with:\n\n```ruby\n\u003C%= link_to 'About', page_path('about') %>\n```\n\nYou can nest pages in a directory structure, if that makes sense from a URL perspective for you:\n\n```ruby\n\u003C%= link_to 'Q4 Reports', page_path('about\u002Fcorporate\u002Fpolicies\u002FHR\u002Fen_US\u002Fbiz\u002Fsales\u002FQuarter-Four') %>\n```\n\nBam.\n\nYou can also get a list of your static pages by calling `HighVoltage.page_ids`\nThis might be useful if you need to build a sitemap. For example, if you are\nusing the [sitemap_generator](https:\u002F\u002Fgithub.com\u002Fkjvarga\u002Fsitemap_generator) gem,\nyou could add something like this to your sitemap config file:\n\n```ruby\nHighVoltage.page_ids.each do |page|\n  add page, changefreq: 'monthly'\nend\n```\n\n## Configuration\n\n#### Routing overview\n\nBy default, the static page routes will be like \u002Fpages\u002F:id (where :id is the view filename).\n\nIf you want to route to a static page in another location (for example, a homepage), do this:\n\n```ruby\nget 'pages\u002Fhome' => 'high_voltage\u002Fpages#show', id: 'home'\n```\n\nIn that case, you'd need an `app\u002Fviews\u002Fpages\u002Fhome.html.erb` file.\n\nGenerally speaking, you need to route to the 'show' action with an `:id` param of the view filename.\n\nHigh Voltage will generate a named route method of `page_path`. If you want to generate\nyour own named route (with the :as routing option), make sure not to use `:page`\nas it will conflict with the High Voltage named route.\n\n#### Specifying a root path\n\nYou can configure the root route to a High Voltage page like this:\n\n```ruby\n# config\u002Finitializers\u002Fhigh_voltage.rb\nHighVoltage.configure do |config|\n  config.home_page = 'home'\nend\n```\n\nWhich will render the page from `app\u002Fviews\u002Fpages\u002Fhome.html.erb` when the '\u002F'\nroute of the site is accessed.\n\nNote: High Voltage also creates a search engine friendly 301 redirect. Any attempt to\naccess the path '\u002Fhome' will be redirected to '\u002F'.\n\n#### Top-level routes\n\nYou can remove the directory `pages` from the URL path and serve up routes from\nthe root of the domain path:\n\n    http:\u002F\u002Fwww.example.com\u002Fabout\n    http:\u002F\u002Fwww.example.com\u002Fcompany\n\nWould look for corresponding files:\n\n    app\u002Fviews\u002Fpages\u002Fabout.html.erb\n    app\u002Fviews\u002Fpages\u002Fcompany.html.erb\n\nThis is accomplished by setting the `route_drawer` to `HighVoltage::RouteDrawers::Root`\n\n```ruby\n# config\u002Finitializers\u002Fhigh_voltage.rb\nHighVoltage.configure do |config|\n  config.route_drawer = HighVoltage::RouteDrawers::Root\nend\n```\n\n#### Disabling routes\n\nThe default routes can be completely removed by setting the `routes` to `false`:\n\n```ruby\n# config\u002Finitializers\u002Fhigh_voltage.rb\nHighVoltage.configure do |config|\n  config.routes = false\nend\n```\n\n#### Specifying Rails engine for routes\n\nIf you are using multiple Rails engines within your application, you can\nspecify which engine to define the default HighVoltage routes on.\n\n```ruby\n# config\u002Finitializers\u002Fhigh_voltage.rb\nHighVoltage.configure do |config|\n  config.parent_engine = MyEngine\nend\n```\n\n#### Page titles and meta-data\n\nWe suggest using `content_for` and `yield` for setting custom page titles and\nmeta-data on High Voltage pages.\n\n```ruby\n# app\u002Fviews\u002Fpages\u002Fabout.html.erb\n\u003C% content_for :page_title, 'About Us - Custom page title' %>\n```\n\nThen print the contents of `:title` into the layout:\n\n```ruby\n# app\u002Fviews\u002Flayouts\u002Fapplication.html.erb\n\u003Ctitle>\u003C%= yield(:page_title) %>\u003C\u002Ftitle>\n```\n\n#### Content path\n\nHigh Voltage uses a default path and folder of 'pages', i.e. 'url.com\u002Fpages\u002Fcontact',\n'app\u002Fviews\u002Fpages'.\n\nYou can change this in an initializer:\n\n```ruby\n# config\u002Finitializers\u002Fhigh_voltage.rb\nHighVoltage.configure do |config|\n  config.content_path = 'site\u002F'\nend\n```\n\n#### Caching\n\nBuilt in caching support has been removed in HighVoltage. See [PR 221](https:\u002F\u002Fgithub.com\u002Fthoughtbot\u002Fhigh_voltage\u002Fpull\u002F221).\n\nPage caching and action caching can be done via Rails. Visit the [Caching with\nRails: An overview](http:\u002F\u002Fguides.rubyonrails.org\u002Fcaching_with_rails.html) guide\nfor more details. You can utilize the methods described there by overriding the\nHighVoltage controller as described [below](#override).\n\n## Override\n\nMost common reasons to override?\n\n- You need authentication around the pages to make sure a user is signed in.\n- You need to render different layouts for different pages.\n- You need to render a partial from the `app\u002Fviews\u002Fpages` directory.\n- You need to use your own Page resource and would like to use StaticPage resource for high voltage\n\nCreate a `PagesController` of your own:\n\n    $ rails generate controller pages\n\nDisable the default routes:\n\n```ruby\n# config\u002Finitializers\u002Fhigh_voltage.rb\nHighVoltage.configure do |config|\n  config.routes = false\nend\n```\n\nDefine a route for the new `PagesController`:\n\n```ruby\n# config\u002Froutes.rb\nget \"\u002Fpages\u002F*id\" => 'pages#show', as: :page, format: false\n\n# if routing the root path, update for your controller\nroot to: 'pages#show', id: 'home'\n```\n\nThen modify new `PagesController` to include the High Voltage static page concern:\n\n```ruby\n# app\u002Fcontrollers\u002Fpages_controller.rb\nclass PagesController \u003C ApplicationController\n  include HighVoltage::StaticPage\n\n  before_action :authenticate\n  layout :layout_for_page\n\n  private\n\n  def layout_for_page\n    case params[:id]\n    when 'home'\n      'home'\n    else\n      'application'\n    end\n  end\nend\n```\n\nTo set up a different layout for all High Voltage static pages, use an initializer:\n\n```ruby\n# config\u002Finitializers\u002Fhigh_voltage.rb\nHighVoltage.configure do |config|\n  config.layout = 'your_layout'\nend\n```\n\nTo use StaticPage resource, turn off routing and use this route:\n\n```ruby\nget \"\u002Fstatic_pages\u002F*id\" => 'high_voltage\u002Fpages#show', as: :static_page, format: false\n```\n\n## Custom finding\n\nYou can further control the algorithm used to find pages by overriding\nthe `page_finder_factory` method:\n\n```ruby\n# app\u002Fcontrollers\u002Fpages_controller.rb\nclass PagesController \u003C ApplicationController\n  include HighVoltage::StaticPage\n\n  private\n\n  def page_finder_factory\n    Rot13PageFinder\n  end\nend\n```\n\nThe easiest thing is to subclass `HighVoltage::PageFinder`, which\nprovides you with `page_id`:\n\n```ruby\nclass Rot13PageFinder \u003C HighVoltage::PageFinder\n  def find\n    paths = super.split('\u002F')\n    directory = paths[0..-2]\n    filename = paths[-1].tr('a-z','n-za-m')\n\n    File.join(*directory, filename)\n  end\nend\n```\n\nUse this to create a custom file mapping, clean filenames for your file\nsystem, A\u002FB test, and so on.\n\n## Localization\n\n[Rails I18n guides](http:\u002F\u002Fguides.rubyonrails.org\u002Fi18n.html).\n\nAdd a before filter to the Application controller\n\n```ruby\n# app\u002Fcontrollers\u002Fapplication_controller.rb\nbefore_action :set_locale\n\ndef set_locale\n  I18n.locale = params[:locale] || I18n.default_locale\nend\n```\n\nDisable the default High Voltage routes\n\n```ruby\n# config\u002Finitializers\u002Fhigh_voltage.rb\nHighVoltage.configure do |config|\n  config.routes = false\nend\n```\n\n```ruby\n# config\u002Froutes.rb\nscope \"\u002F:locale\", locale: \u002Fen|bn|hi\u002F do\n  get \"\u002Fpages\u002F:id\" => \"high_voltage\u002Fpages#show\", :as => :page, :format => false\nend\n```\n\nAdd a static page to the project\n\n```\n# app\u002Fviews\u002Fpages\u002Fabout.html.erb\n\u003C%= t \"hello\" %>\n```\n\nMake sure that there are corresponding locale files\n\n```\n\u002Fconfig\u002Flocale\u002Fbn.yml\n\u002Fconfig\u002Flocale\u002Fen.yml\n\u002Fconfig\u002Flocale\u002Fhi.yml\n```\n\nOne last note is there is a [known\nissue](https:\u002F\u002Fgithub.com\u002Fthoughtbot\u002Fhigh_voltage\u002Fissues\u002F59) with High Voltage.\n\nYou'll need to specify routes like this `\u003C%= link_to \"About Us\", page_path(id:\n\"about\") %>`\n\n## Testing\n\nYou can test your static pages using [RSpec](https:\u002F\u002Fgithub.com\u002Frspec\u002Frspec-rails)\nand [shoulda-matchers](https:\u002F\u002Fgithub.com\u002Fthoughtbot\u002Fshoulda-matchers):\n\n```ruby\n# spec\u002Fcontrollers\u002Fpages_controller_spec.rb\ndescribe PagesController, '#show' do\n  %w(earn_money screencast about contact).each do |page|\n    context \"on GET to \u002Fpages\u002F#{page}\" do\n      before do\n        get :show, id: page\n      end\n\n      it { should respond_with(:success) }\n      it { should render_template(page) }\n    end\n  end\nend\n```\n\nIf you're not using a custom PagesController be sure to test\n`HighVoltage::PagesController` instead.\n\nEnjoy!\n\n## Contributing\n\nPlease see [CONTRIBUTING.md].\nThank you, [contributors]!\n\n[CONTRIBUTING.md]: \u002FCONTRIBUTING.md\n[contributors]: https:\u002F\u002Fgithub.com\u002Fthoughtbot\u002Fhigh_voltage\u002Fgraphs\u002Fcontributors\n\n## License\n\nHigh Voltage is copyright © 2009 thoughtbot. It is free software, and may\nbe redistributed under the terms specified in the [`LICENSE`] file.\n\n[`LICENSE`]: \u002FMIT-LICENSE\n\n\u003C!-- START \u002Ftemplates\u002Ffooter.md -->\n## About thoughtbot\n\n![thoughtbot](https:\u002F\u002Fthoughtbot.com\u002Fthoughtbot-logo-for-readmes.svg)\n\nThis repo is maintained and funded by thoughtbot, inc.\nThe names and logos for thoughtbot are trademarks of thoughtbot, inc.\n\nWe love open source software!\nSee [our other projects][community].\nWe are [available for hire][hire].\n\n[community]: https:\u002F\u002Fthoughtbot.com\u002Fcommunity?utm_source=github\n[hire]: https:\u002F\u002Fthoughtbot.com\u002Fhire-us?utm_source=github\n\n\u003C!-- END \u002Ftemplates\u002Ffooter.md -->\n","High Voltage 是一个用于在 Rails 应用中轻松添加静态页面的引擎。其核心功能是允许开发者通过简单的配置将如“关于我们”、“联系方式”等静态页面集成到应用中，而无需编写额外的控制器或路由代码。该项目支持页面嵌套，并且可以自动生成站点地图所需的页面列表，便于SEO优化。它非常适合需要快速搭建包含多个静态信息页面（例如营销页面、法律声明等）的Web应用场景。尽管目前处于维护模式，但仍然会定期更新以保持与最新版Ruby和Rails的兼容性。",2,"2026-06-11 03:14:46","top_language"]