sitepress-server 0.1.28 → 2.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 35899ff09d858ef96d2b147e23e751fc56aabfd8
4
- data.tar.gz: 953eb864bc7b4ef5fea01a4813ed40ea219d4bae
2
+ SHA256:
3
+ metadata.gz: ba51458e7d83de68f9b948e85139e195a8b6dd03a089d8f75890c47dcc9133a9
4
+ data.tar.gz: 8fd724ed66f77cd6e82f86c376dd1a055ad2de4d7f9f0bc8f897a59b96587f02
5
5
  SHA512:
6
- metadata.gz: cd53a839c1306f58ca6cab94f60e005d9b9c24e3d123852509eb418fa637f663236b9696cf11d9b150a1675a3e048bf80af9ec039b032950545138f3ed14931c
7
- data.tar.gz: cc59248b0601d5026cf11a74bc0d9716167762e240ca21319805e50830d1f133524235c16f074fb93969e8c0a7dae80b0bc0a266349a4de807d32f51dcd26f87
6
+ metadata.gz: 2f8bdbe5d16c12bfa0aaf0777e3fdc34bcb4c13f2dc7640b2ce4564731ff20427b64375363ccb7a54e4c295664ee4aef011d8353917fe8a987f196aabfa77b2b
7
+ data.tar.gz: 2c31a00f2f7824b8e7409748b93fb1cbe058923ad4cd1cdde6184087b1cc404eafb007783d446679973c05855d449801ac4a7f345646d5b6af8565f6c425657c
@@ -1,8 +1,5 @@
1
1
  require "sitepress-core"
2
2
 
3
3
  module Sitepress
4
- autoload :AssetTemplate, "sitepress/asset_template"
5
- autoload :HelperLoader, "sitepress/helper_loader"
6
- autoload :RenderingContext, "sitepress/rendering_context"
7
- autoload :Server, "sitepress/server"
4
+ autoload :Server, "sitepress/server"
8
5
  end
@@ -0,0 +1,18 @@
1
+ # Rails doesn't compile .scss or .sass files that are outside of the asset pipeline,
2
+ # so we add support for that here with this patch.
3
+ module Sass
4
+ class SassCHandler
5
+ def call(template, source = template.source)
6
+ SassC::Engine.new(source).render.inspect + '.html_safe'
7
+ end
8
+ end
9
+
10
+ class SassHandler
11
+ def call(template, source = template.source)
12
+ SassC::Engine.new(SassC::Sass2Scss.convert(source)).render.inspect + '.html_safe'
13
+ end
14
+ end
15
+ end
16
+
17
+ ActionView::Template.register_template_handler :sass, Sass::SassHandler.new
18
+ ActionView::Template.register_template_handler :scss, Sass::SassCHandler.new
@@ -1,23 +1,48 @@
1
+ require "action_controller/railtie"
2
+ require "sprockets/railtie"
3
+ require "sitepress-rails"
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(*Rails.groups)
8
+
9
+ # Configure the rails application.
1
10
  module Sitepress
2
- # Run a Sitepress site as a rack app.
3
- class Server
4
- def initialize(site: )
5
- @site = site
6
- end
7
-
8
- def call(env)
9
- req = Rack::Request.new(env)
10
- resource = @site.get req.path
11
-
12
- if resource
13
- mime_type = resource.mime_type.to_s
14
- context = RenderingContext.new(resource: resource, site: @site)
15
- body = context.render
16
-
17
- [ 200, {"Content-Type" => mime_type}, Array(body) ]
18
- else
19
- [ 404, {"Content-Type" => "text/plain"}, ["Not Found"]]
20
- end
21
- end
11
+ class Server < Rails::Application
12
+ # Paths unique to Sitepress
13
+ config.root = File.join(File.dirname(__FILE__), "../../rails")
14
+
15
+ # Boilerplate required to get Rails to boot.
16
+ config.eager_load = false # necessary to silence warning
17
+ config.cache_classes = false # reload everything since this is dev env.
18
+
19
+ config.secret_key_base = SecureRandom.uuid # Rails won't start without this
20
+
21
+ # Setup routes
22
+ routes.append { root to: "site#show" }
23
+ routes.append { get "*resource_path", controller: "site", action: "show", as: :page, format: false }
24
+
25
+ # A logger without a formatter will crash when Sprockets is enabled.
26
+ logger = ActiveSupport::Logger.new(STDOUT)
27
+ logger.formatter = config.log_formatter
28
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
29
+
30
+ # Debug mode disables concatenation and preprocessing of assets.
31
+ # This option may cause significant delays in view rendering with a large
32
+ # number of complex assets.
33
+ config.assets.debug = false
34
+
35
+ # Suppress logger output for asset requests.
36
+ config.assets.quiet = true
37
+
38
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
39
+ config.assets.compile = true
40
+
41
+ # Allow any host to connect to the development server. The actual binding is
42
+ # controlled by server in the `sitepress-cli`; not by Rails.
43
+ config.hosts << proc { true } if config.respond_to? :hosts
22
44
  end
23
45
  end
46
+
47
+ # Load the SassC template handler if SassC is installed as part of this stand-alone server.
48
+ require_relative "sass_template_handlers" if defined? SassC::Engine
File without changes
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
@@ -0,0 +1,28 @@
1
+ class SiteController < ApplicationController
2
+ DEFAULT_SITE_LAYOUT = "layouts/layout".freeze
3
+
4
+ # This `rescue_from` order is important; it must come before the
5
+ # `include Sitepress::SitePages` statement; otherwise exceptions
6
+ # won't be properly handled.
7
+ rescue_from Exception, with: :sitepress_error
8
+
9
+ include Sitepress::SitePages
10
+
11
+ layout :site_layout
12
+
13
+ private
14
+ def site_layout
15
+ DEFAULT_SITE_LAYOUT if template_exists? DEFAULT_SITE_LAYOUT
16
+ end
17
+
18
+ def sitepress_error(exception)
19
+ @title = "Sitepress error in #{current_page.asset.path}".html_safe
20
+ @exception = exception
21
+ render "error", layout: "sitepress", status: :internal_server_error
22
+ end
23
+
24
+ def page_not_found(exception)
25
+ @title = "Sitepress page #{params[:resource_path].inspect} not found"
26
+ render "page_not_found", layout: "sitepress", status: :not_found
27
+ end
28
+ end
@@ -0,0 +1,26 @@
1
+ module ApplicationHelper
2
+ DEFAULT_TITLE_KEY = "title".freeze
3
+
4
+ DEFAULT_ORDER_KEY = "order".freeze
5
+
6
+ # Links to a Sitepress::Resource. If the link does not have a block, the `title`
7
+ # attribute from Resource#data is used to create the text link.
8
+ def link_to_page(page, *args, title_key: DEFAULT_TITLE_KEY, **kwargs, &block)
9
+ if block_given?
10
+ link_to page.request_path, *args, **kwargs, &block
11
+ else
12
+ link_to page.data[DEFAULT_TITLE_KEY], page.request_path, *args, **kwargs
13
+ end
14
+ end
15
+
16
+ # Render a block within a layout. This is a useful, and prefered way, to handle
17
+ # nesting layouts, within Sitepress
18
+ def render_layout(layout, locals = {}, &block)
19
+ render inline: capture(&block), layout: "layouts/#{layout}", locals: locals
20
+ end
21
+
22
+ # Orders pages via the
23
+ def order_pages(pages, order_key: DEFAULT_ORDER_KEY)
24
+ pages.sort_by { |r| r.data.fetch(order_key, Float::INFINITY) }
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='utf-8'>
5
+ <title><%= @title || "Sitepress" %></title>
6
+ <link href='/_sitepress/stylesheets/site.css' rel='stylesheet' type='text/css'>
7
+ </head>
8
+ <body>
9
+ <header>
10
+ <img src='/_sitepress/images/logo.svg' id='logo'>
11
+ <h1 id="title"><%= @title || "Sitepress" %></h1>
12
+ </header>
13
+ <main>
14
+ <%= yield %>
15
+ </main>
16
+ </body>
17
+ <footer>
18
+ Running version Sitepress <%= Sitepress::VERSION %>. Visit <a href="https://sitepress.cc/">sitepress.cc</a> for documentation, help, and updates.
19
+ </footer>
20
+ </html>
@@ -0,0 +1,30 @@
1
+ <h2><%= @exception.class %>: <%= @exception.message %> in <%= current_page.asset.path %>:<%= @exception.line_number %></h2>
2
+ <h3>Source</h3>
3
+
4
+ <code>
5
+ <pre><%= current_page.asset.path %>:<%= @exception.line_number %>
6
+ <%= @exception.annotated_source_code.join("\n") %></pre>
7
+ </code>
8
+
9
+ <h3>Backtrace</h3>
10
+ <code>
11
+ <pre><%= @exception.backtrace.join("\n") %></pre>
12
+ </code>
13
+
14
+ <h3>Resources</h3>
15
+ <table>
16
+ <thead>
17
+ <th>Request path</th>
18
+ <th>Asset path</th>
19
+ <th>Media type</th>
20
+ </thead>
21
+ <tbody>
22
+ <% site.resources.each do |resource| %>
23
+ <tr>
24
+ <td><%= link_to resource.request_path, resource.request_path %></td>
25
+ <td><%= resource.asset.path %></td>
26
+ <td><%= resource.asset.mime_type %></td>
27
+ </tr>
28
+ <% end %>
29
+ </tbody>
30
+ </table>
@@ -0,0 +1,17 @@
1
+ <h2>Available resources</h2>
2
+ <table>
3
+ <thead>
4
+ <th>Request path</th>
5
+ <th>Asset path</th>
6
+ <th>Mime type</th>
7
+ </thead>
8
+ <tbody>
9
+ <% site.resources.each do |resource| %>
10
+ <tr>
11
+ <td><%= link_to resource.request_path, resource.request_path %></td>
12
+ <td><%= resource.asset.path %></td>
13
+ <td><%= resource.asset.mime_type %></td>
14
+ </tr>
15
+ <% end %>
16
+ </tbody>
17
+ </table>
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="895px" height="895px" viewBox="0 0 895 895" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <title>Sitepress logo</title>
4
+ <desc>A static and dynamic website builder</desc>
5
+ <defs></defs>
6
+ <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
7
+ <g id="logo" fill="#ffffff">
8
+ <path d="M334.72,537.93 C325.82,530.6 313.41,526.88 297.83,526.88 L254.05,526.88 L254.05,618.4 L297.84,618.4 C313.41,618.4 325.84,614.63 334.72,607.2 C343.6,599.77 348.01,588.2 348.01,572.49 C348.01,556.78 343.54,545.2 334.72,537.93 L334.72,537.93 Z" id="Shape"></path>
9
+ <path d="M859.29,274.59 C770.211759,62.9463102 535.248488,-46.7589164 315.795351,20.8303235 C96.3422149,88.4195635 -36.1856795,311.308174 9.24445457,536.395018 C54.6745886,761.481862 263.278739,915.518494 491.767697,892.697877 C720.256655,869.87726 894.274848,677.625748 894.29,448 C894.373576,388.434111 882.470683,329.460375 859.29,274.59 L859.29,274.59 Z M573.53,155.3 C573.53,150.7 576.17,148.06 580.77,148.06 L684.32,148.06 C688.73,148.06 691.27,150.59 691.27,155.01 C691.27,159.79 688.74,162.54 684.32,162.54 L588,162.54 L588,249 L632.54,249 C636.95,249 639.48,251.74 639.48,256.53 C639.48,260.94 636.95,263.48 632.54,263.48 L588,263.48 L588,350.23 L684.32,350.23 C688.73,350.23 691.27,352.97 691.27,357.76 C691.27,362.17 688.74,364.71 684.32,364.71 L580.77,364.71 C576.17,364.71 573.53,362.07 573.53,357.47 L573.53,155.3 Z M401.53,89.3 C402.779293,87.9227726 404.571684,87.1655789 406.43,87.23 L553.75,87.23 C558.27,87.23 560.53,89.3666667 560.53,93.64 C560.53,98.4133333 558.27,100.8 553.75,100.8 L487.06,100.8 L487.06,355.91 C487.06,360.43 484.8,362.69 480.28,362.69 C475.76,362.69 473.5,360.43 473.5,355.91 L473.5,100.83 L406.43,100.83 C404.571176,100.897181 402.777669,100.139516 401.53,98.76 C399.018254,96.1222984 399.018254,91.9777016 401.53,89.34 L401.53,89.3 Z M361.08,93.63 C361.08,89.3633333 363.34,87.2266667 367.86,87.22 C372.38,87.2133333 374.64,89.35 374.64,93.63 L374.64,355.91 C374.64,360.43 372.38,362.69 367.86,362.69 C363.34,362.69 361.08,360.43 361.08,355.91 L361.08,93.63 Z M208.57,329.63 C210.15,327.79 211.7,326.89 213.29,326.89 C214.88,326.89 216.79,328.24 219.49,331.55 C221.62,334.16 224.09,337.02 226.84,340.05 C229.42,342.91 233.97,345.62 240.34,348.11 C247.586888,350.800137 255.270834,352.119225 263,352 C278.29,352 290,348.13 297.82,340.5 C305.64,332.87 309.58,321.57 309.58,306.88 C309.58,297.17 307.85,288.88 304.43,282.35 C301.410563,276.249269 296.784618,271.087433 291.05,267.42 C285.097567,263.784066 278.78788,260.768283 272.22,258.42 L251.58,251.15 C244.726443,248.889218 238.156396,245.84579 232,242.08 C225.705868,238.108684 220.588935,232.525633 217.18,225.91 C213.45,218.97 211.56,210.38 211.56,200.39 C211.56,190.23 213.44,181.39 217.16,174.03 C220.484889,167.084479 225.841413,161.312965 232.52,157.48 C238.378086,154.162981 244.677689,151.694992 251.23,150.15 C257.679927,148.734499 264.266659,148.036922 270.87,148.07 C281.863142,147.943398 292.800246,149.653588 303.23,153.13 C313.87,156.83 318.83,160.66 318.83,165.2 C318.754645,167.219913 317.98465,169.151963 316.65,170.67 C315.09,172.62 313.39,173.6 311.6,173.6 C310.78,173.6 309.49,173.37 304.51,170.6 C300.133975,168.352176 295.540237,166.556229 290.8,165.24 C284.225834,163.369844 277.414361,162.467037 270.58,162.56 C263.351008,162.469822 256.146813,163.422972 249.19,165.39 C243.12,167.2 237.67,171.04 233.01,176.8 C228.35,182.56 226.01,190.16 226.01,199.54 C226.01,207.46 227.72,214.2 231.09,219.54 C234.303387,224.772292 238.912858,229.004278 244.4,231.76 C250.482431,234.769407 256.763789,237.358797 263.2,239.51 C270.06,241.83 277.09,244.44 284.1,247.26 C291.011648,250.019216 297.587203,253.555254 303.7,257.8 C309.78,262.06 314.76,268.35 318.48,276.5 C322.2,284.65 324.04,294.5 324.04,305.98 C324.04,326.24 318.59,341.56 307.84,351.52 C297.09,361.48 282.53,366.45 264.45,366.45 C256.023647,366.517248 247.635543,365.310279 239.57,362.87 C231.93,360.49 225.72,357.61 221.11,354.3 C217.052927,351.515289 213.430344,348.145445 210.36,344.3 C207.64,340.72 206.36,337.7 206.36,335.09 C206.41612,333.079377 207.205725,331.158715 208.58,329.69 L208.57,329.63 Z M128.83,453.11 L296.96,413.11 C299.21742,412.571572 301.590658,413.277552 303.186737,414.962302 C304.782816,416.647052 305.359576,419.054959 304.7,421.28 L296,450.51 L453.2,413.11 C455.45742,412.571572 457.830658,413.277552 459.426737,414.962302 C461.022816,416.647052 461.599576,419.054959 460.94,421.28 L452.27,450.51 L609.47,413.11 C611.72742,412.571572 614.100658,413.277552 615.696737,414.962302 C617.292816,416.647052 617.869576,419.054959 617.21,421.28 L608.54,450.51 L765.74,413.11 C767.999705,412.574102 770.373657,413.284449 771.967611,414.973462 C773.561565,416.662475 774.133361,419.073551 773.467611,421.298462 C772.80186,423.523373 770.999705,425.224102 768.74,425.76 L600.61,465.76 C598.35258,466.298428 595.979342,465.592448 594.383263,463.907698 C592.787184,462.222948 592.210424,459.815041 592.87,457.59 L601.54,428.36 L444.34,465.76 C442.08258,466.298428 439.709342,465.592448 438.113263,463.907698 C436.517184,462.222948 435.940424,459.815041 436.6,457.59 L445.27,428.36 L288.07,465.76 C285.81258,466.298428 283.439342,465.592448 281.843263,463.907698 C280.247184,462.222948 279.670424,459.815041 280.33,457.59 L289,428.36 L131.8,465.76 C131.305299,465.878067 130.798593,465.93847 130.29,465.94 C126.983263,465.951866 124.194638,463.479226 123.810649,460.194838 C123.426659,456.910451 125.569705,453.861232 128.79,453.11 L128.83,453.11 Z M219.36,568.38 C219.36,586.66 214.64,600.38 205.36,609.03 C196.08,617.68 183.68,622.03 168.41,622.03 L131.51,622.03 L131.51,690.84 C131.51,695.17 128.92,697.76 124.59,697.76 C120.26,697.76 117.67,695.17 117.67,690.84 L117.67,518.64 C117.67,516.86 118.32,512.64 124.31,511.98 L124.58,511.98 L168.38,511.98 C183.63,511.98 196.06,516.32 205.32,524.89 C214.58,533.46 219.32,547.14 219.32,565.43 L219.36,568.38 Z M360.87,727.12 C361.533457,728.352283 361.903078,729.721252 361.95,731.12 C362.033205,733.000791 361.322464,734.830022 359.991243,736.161243 C358.660022,737.492464 356.830791,738.203205 354.95,738.12 C353.896221,738.11813 352.861519,737.838761 351.95,737.31 C350.899467,736.658391 350.007755,735.780345 349.34,734.74 C348.62,733.74 348.06,732.9 347.65,732.28 L347.49,731.96 L346.31,728.7 C345.91,727.92 345.65,727.45 345.49,727.17 L345.26,727.17 L344.84,726.35 L296.63,632.35 L254.05,632.35 L254.05,731.15 C254.05,735.65 251.57,738.15 247.05,738.15 C242.53,738.15 240.05,735.67 240.05,731.15 L240.05,519.6 C240.05,517.4 240.93,513.6 246.86,512.94 L297.78,512.94 C316.68,512.94 332.23,517.65 344,526.94 C355.77,536.23 361.89,551.64 361.89,572.49 C361.89,606.93 344.98,626.76 311.64,631.49 L360.87,727.12 Z M459,644.64 C463.246667,644.64 465.373333,647.016667 465.38,651.77 C465.38,656.023333 463.253333,658.15 459,658.15 L399,658.15 L399,775.22 L525.79,775.22 C530.043333,775.22 532.17,777.596667 532.17,782.35 C532.17,786.603333 530.043333,788.73 525.79,788.73 L392.2,788.73 C387.7,788.73 385.45,786.48 385.45,781.98 L385.45,521.19 C385.45,516.69 387.7,514.44 392.2,514.44 L525.79,514.44 C530.043333,514.44 532.17,516.566667 532.17,520.82 C532.17,525.573333 530.043333,527.95 525.79,527.95 L399,527.95 L399,644.65 L459,644.64 Z M643.77,724.49 C632.69,734.74 617.57,739.93 598.83,739.93 C590.082311,740.000953 581.374084,738.750178 573,736.22 C565.08,733.75 558.65,730.76 553.88,727.34 C549.685777,724.461626 545.941701,720.977041 542.77,717 C540.01,713.36 538.67,710.33 538.67,707.74 C538.734283,705.789092 539.509619,703.928997 540.85,702.51 C542.39,700.72 543.85,699.86 545.33,699.86 C546.81,699.86 548.69,701.25 551.33,704.51 C553.57,707.26 556.16,710.26 559.03,713.42 C561.9,716.58 566.61,719.36 573.36,722 C580.11,724.64 588.19,726 597.28,726 C613.41,726 625.79,721.9 634.07,713.81 C642.35,705.72 646.53,693.81 646.53,678.26 C646.53,668.02 644.7,659.26 641.08,652.36 C637.874282,645.8902 632.964805,640.41717 626.88,636.53 C620.626732,632.715387 613.998721,629.552171 607.1,627.09 L585.53,619.5 C578.407687,617.155538 571.579303,613.998039 565.18,610.09 C558.689278,605.99337 553.413379,600.234076 549.9,593.41 C546.05,586.24 544.1,577.36 544.1,567.02 C544.1,556.49 546.05,547.32 549.88,539.75 C553.71,532.18 559.06,526.39 565.69,522.75 C571.760835,519.311259 578.289388,516.752362 585.08,515.15 C591.7762,513.680181 598.61447,512.955774 605.47,512.99 C616.890766,512.856493 628.25367,514.630891 639.09,518.24 C650,522 655,525.78 655,530.24 C654.916423,532.213781 654.157409,534.098961 652.85,535.58 C651.34,537.47 649.72,538.42 648.03,538.42 C647.19,538.42 645.75,538.05 640.91,535.34 C636.30085,532.971571 631.462578,531.07848 626.47,529.69 C619.544449,527.721432 612.369222,526.771473 605.17,526.87 C597.558092,526.781289 589.97323,527.791706 582.65,529.87 C576.19,531.8 570.4,535.87 565.46,541.99 C560.52,548.11 558.04,556.19 558.04,566.12 C558.04,574.52 559.85,581.66 563.43,587.36 C566.838785,592.927174 571.736573,597.43009 577.57,600.36 C583.94981,603.517486 590.538592,606.233855 597.29,608.49 C604.46,610.91 611.79,613.63 619.1,616.57 C626.282202,619.451958 633.112871,623.142398 639.46,627.57 C645.73,631.96 650.86,638.45 654.71,646.87 C658.56,655.29 660.47,665.52 660.47,677.43 C660.51,698.35 654.87,714.21 643.76,724.49 L643.77,724.49 Z M765.92,686.38 C756.67,694.94 744.07,699.29 728.49,699.29 C721.242168,699.348298 714.027215,698.309885 707.09,696.21 C701.428334,694.592844 696.056089,692.095694 691.17,688.81 C687.654637,686.392813 684.517177,683.467661 681.86,680.13 C679.44,676.94 678.27,674.23 678.27,671.84 C678.322752,669.953085 679.062359,668.150293 680.35,666.77 C681.85,665.02 683.35,664.18 684.94,664.18 C686.53,664.18 688.35,665.41 690.81,668.43 C692.62,670.65 694.71,673.07 697.04,675.63 C699.16,677.97 702.92,680.21 708.24,682.29 C714.32226,684.514605 720.764973,685.589521 727.24,685.46 C740.04,685.46 749.82,682.24 756.33,675.89 C762.84,669.54 766.1,660.12 766.1,647.83 C766.1,639.7 764.65,632.83 761.8,627.32 C759.297736,622.247998 755.460166,617.95407 750.7,614.9 C745.678978,611.841159 740.357883,609.304592 734.82,607.33 L717.27,601.15 C711.38642,599.215288 705.745772,596.608041 700.46,593.38 C694.996887,589.94318 690.550437,585.110082 687.58,579.38 C684.35,573.38 682.71,565.93 682.71,557.3 C682.71,548.67 684.34,540.87 687.55,534.53 C690.448442,528.485526 695.11436,523.46391 700.93,520.13 C705.977623,517.274361 711.405115,515.149827 717.05,513.82 C722.592378,512.592976 728.253448,511.9826 733.93,512 C743.367043,511.889982 752.756198,513.356827 761.71,516.34 C771.11,519.61 775.49,523.1 775.49,527.34 C775.433713,529.229237 774.727297,531.041195 773.49,532.47 C772.02,534.31 770.37,535.25 768.6,535.25 C767.77,535.25 766.6,535.04 762.2,532.58 C758.525602,530.696709 754.669063,529.19229 750.69,528.09 C745.162798,526.517786 739.435902,525.759815 733.69,525.84 C727.607224,525.759866 721.544725,526.558095 715.69,528.21 C710.365486,529.922249 705.692777,533.223505 702.3,537.67 C698.48,542.39 696.54,548.74 696.54,556.53 C696.54,563.13 697.95,568.72 700.74,573.16 C703.393404,577.491303 707.202977,580.996109 711.74,583.28 C716.884382,585.823473 722.196793,588.011919 727.64,589.83 C733.5,591.83 739.5,594.04 745.46,596.44 C751.395098,598.808559 757.041415,601.844754 762.29,605.49 C767.58,609.19 771.89,614.65 775.12,621.7 C778.35,628.75 779.92,637.22 779.92,647.1 C779.95,664.54 775.23,677.76 765.92,686.38 L765.92,686.38 Z" id="Shape"></path>
10
+ <path d="M168.39,525.81 L131.51,525.81 L131.51,608.24 L168.39,608.24 C180.34,608.24 189.61,604.91 195.94,598.35 C202.27,591.79 205.52,581.68 205.52,568.35 L205.52,565.35 C205.52,552.06 202.3,542.03 195.95,535.52 C189.6,529.01 180.34,525.81 168.39,525.81 L168.39,525.81 Z" id="Shape"></path>
11
+ </g>
12
+ </g>
13
+ </svg>
@@ -0,0 +1,84 @@
1
+ body {
2
+ font-family: sans-serif;
3
+ margin: 2rem;
4
+ padding: 0;
5
+ background: hsl(23,39%,26%);
6
+ color: #fefefe;
7
+ }
8
+
9
+ main {
10
+ color: #000;
11
+ background: #fefefe;
12
+ padding: 2rem;
13
+ border-radius: 0.5rem;
14
+ }
15
+
16
+ header {
17
+ display: flex;
18
+ flex-direction: row;
19
+ align-items: center;
20
+ margin-bottom: 1rem;
21
+ }
22
+
23
+ #logo {
24
+ max-width: 4rem;
25
+ max-height: 4rem;
26
+ }
27
+
28
+ #title {
29
+ margin-left: 1rem;
30
+ }
31
+
32
+ footer {
33
+ margin: 4rem 1rem;
34
+ text-align: center;
35
+ }
36
+ footer a {
37
+ color: #fefefe;
38
+ }
39
+
40
+ pre {
41
+ overflow: scroll;
42
+ }
43
+
44
+ code {
45
+ display: block;
46
+ color: #000;
47
+ background: hsl(23,39%,90%);
48
+ padding: 1rem;
49
+ border-radius: 0.5rem;
50
+ }
51
+
52
+ h2, a {
53
+ color: hsl(23,39%,26%);
54
+ }
55
+
56
+ h3 {
57
+ color: hsl(23,39%,5%);
58
+ }
59
+
60
+ table td, table th {
61
+ text-align: left;
62
+ padding: 0.25rem;
63
+ }
64
+
65
+ @media (prefers-color-scheme: dark) {
66
+ h2, a {
67
+ color: hsl(23,39%,90%);
68
+ }
69
+
70
+ h3 {
71
+ color: hsl(23,39%,85%);
72
+ }
73
+
74
+ main {
75
+ color: hsl(23,39%,85%);
76
+ background: hsl(23,39%,10%);
77
+ }
78
+
79
+ code {
80
+ color: hsl(23,39%,85%);
81
+ background: hsl(23,39%,7%);
82
+ }
83
+ }
84
+
@@ -17,10 +17,11 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_development_dependency "haml", "~> 4.0"
21
20
  spec.add_development_dependency "rack-test"
22
- spec.add_development_dependency "rack"
23
21
 
24
- spec.add_runtime_dependency "sitepress-core", spec.version
25
- spec.add_runtime_dependency "tilt", "~> 2.0"
22
+ spec.add_runtime_dependency "sitepress-rails", spec.version
23
+ spec.add_runtime_dependency "haml-rails"
24
+ spec.add_runtime_dependency "sass-rails"
25
+ spec.add_runtime_dependency "markdown-rails"
26
+ spec.add_runtime_dependency "webrick"
26
27
  end
metadata CHANGED
@@ -1,37 +1,51 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitepress-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.28
4
+ version: 2.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-10 00:00:00.000000000 Z
11
+ date: 2021-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: haml
14
+ name: rack-test
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rack-test
28
+ name: sitepress-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.0.beta2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.0.beta2
41
+ - !ruby/object:Gem::Dependency
42
+ name: haml-rails
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
- type: :development
48
+ type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
@@ -39,13 +53,13 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rack
56
+ name: sass-rails
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
- type: :development
62
+ type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
@@ -53,34 +67,34 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: sitepress-core
70
+ name: markdown-rails
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - '='
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: 0.1.28
75
+ version: '0'
62
76
  type: :runtime
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - '='
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: 0.1.28
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: tilt
84
+ name: webrick
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - "~>"
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
- version: '2.0'
89
+ version: '0'
76
90
  type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - "~>"
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
- version: '2.0'
83
- description:
96
+ version: '0'
97
+ description:
84
98
  email:
85
99
  - bradgessler@gmail.com
86
100
  executables: []
@@ -88,15 +102,22 @@ extensions: []
88
102
  extra_rdoc_files: []
89
103
  files:
90
104
  - lib/sitepress-server.rb
91
- - lib/sitepress/asset_template.rb
92
- - lib/sitepress/helper_loader.rb
93
- - lib/sitepress/rendering_context.rb
105
+ - lib/sitepress/sass_template_handlers.rb
94
106
  - lib/sitepress/server.rb
107
+ - rails/app/assets/config/manifest.js
108
+ - rails/app/controllers/application_controller.rb
109
+ - rails/app/controllers/site_controller.rb
110
+ - rails/app/helpers/application_helper.rb
111
+ - rails/app/views/layouts/sitepress.html.erb
112
+ - rails/app/views/site/error.html.erb
113
+ - rails/app/views/site/page_not_found.html.erb
114
+ - rails/public/_sitepress/images/logo.svg
115
+ - rails/public/_sitepress/stylesheets/site.css
95
116
  - sitepress-server.gemspec
96
117
  homepage: https://github.com/sitepress/sitepress
97
118
  licenses: []
98
119
  metadata: {}
99
- post_install_message:
120
+ post_install_message:
100
121
  rdoc_options: []
101
122
  require_paths:
102
123
  - lib
@@ -107,13 +128,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
128
  version: '0'
108
129
  required_rubygems_version: !ruby/object:Gem::Requirement
109
130
  requirements:
110
- - - ">="
131
+ - - ">"
111
132
  - !ruby/object:Gem::Version
112
- version: '0'
133
+ version: 1.3.1
113
134
  requirements: []
114
- rubyforge_project:
115
- rubygems_version: 2.6.11
116
- signing_key:
135
+ rubygems_version: 3.2.3
136
+ signing_key:
117
137
  specification_version: 4
118
138
  summary: Sitepress rack app for stand-alone of embedded usage.
119
139
  test_files: []
@@ -1,46 +0,0 @@
1
- require "tilt"
2
-
3
- module Sitepress
4
- # Since we use Frontmatter, we have to do some parsing to
5
- # get a Tilt template working properly.
6
- class AssetTemplate
7
- attr_reader :asset
8
-
9
- def initialize(asset)
10
- @asset = ceorce_asset(asset)
11
- end
12
-
13
- def render(*args, &block)
14
- if renderable_resource?
15
- template.render(*args, &block)
16
- else
17
- asset.body
18
- end
19
- end
20
-
21
- def template
22
- @_template ||= engine.new{ asset.body }
23
- end
24
-
25
- private
26
- def renderable_resource?
27
- asset.template_extensions.any?
28
- end
29
-
30
- def engine
31
- @_engine ||= Tilt[asset.path]
32
- end
33
-
34
- # TODO: Replace this with a "fuzzy asset finder"
35
- def ceorce_asset(assetish)
36
- case assetish
37
- when String
38
- Asset.new(path: assetish)
39
- when Asset
40
- assetish
41
- else
42
- raise RuntimeError, "#{assetish.inspect} cannot be coerce into Sitepress::Asset"
43
- end
44
- end
45
- end
46
- end
@@ -1,35 +0,0 @@
1
- module Sitepress
2
- # Loads modules into an isolated namespace that will be
3
- # used for the rendering context. This loader is designed to
4
- # be immutable so that it throws away the constants and modules
5
- # on each load.
6
- #
7
- # TODO: Rename this to a RenderingContext, or something.
8
- class HelperLoader
9
- def initialize(paths:)
10
- @paths = Array(paths)
11
- end
12
-
13
- def extend_instance(object, locals: {})
14
- modules = helpers
15
- # Locals of rendering context that are accessible from the
16
- # helper modules.
17
- locals.each do |name, value|
18
- object.define_singleton_method(name) { value }
19
- end
20
- # Include the helper modules of the rendering context.
21
- modules.constants.each do |module_name|
22
- object.send(:extend, modules.const_get(module_name))
23
- end
24
- end
25
-
26
- private
27
- def helpers
28
- @_helpers ||= Module.new.tap do |m|
29
- @paths.each do |path|
30
- m.module_eval File.read(path)
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,42 +0,0 @@
1
- module Sitepress
2
- # TODO: We're starting to get too many rendering contexts ... and this
3
- # won't quite fit in with the Tilt rendering context. We'll want to merge
4
- # this and support `capture` so that we can get `wrap_layout` working.
5
- class RenderingContext
6
- attr_reader :resource, :site
7
- alias :current_page :resource
8
-
9
- def initialize(resource:, site:)
10
- @resource = resource
11
- @site = site
12
- # TODO: Remove this from RenderingContext ... it should build
13
- load_helpers
14
- end
15
-
16
- def render(layout: nil, locals: {}, &block)
17
- layout ||= resource.data["layout"]
18
- render_with_layout(layout) { renderer.render(self, **locals, &block) }
19
- end
20
-
21
- private
22
- def render_with_layout(path, &block)
23
- if path
24
- template = AssetTemplate.new(path)
25
- template.render(self, &block)
26
- else
27
- block.call
28
- end
29
- end
30
-
31
- def renderer
32
- @_renderer ||= AssetTemplate.new(resource.asset)
33
- end
34
-
35
- # TODO: This might be accessible from the rendering scope, which wouldn't be good.
36
- # Figure out if this needs to be removed.
37
- def load_helpers
38
- paths = Dir.glob @site.helpers_path.join("**.rb")
39
- HelperLoader.new(paths: paths).extend_instance(self)
40
- end
41
- end
42
- end