2 Commits 7a0aace972 ... fcd66fd096

Author SHA1 Message Date
  Felix Freeman fcd66fd096 Primavera Hacker y Cultura Libre: Recordando a Aaron Swartz 1 year ago
  Felix Freeman fb2e44d53b Update to LeanWeb 0.4 1 year ago

+ 1 - 1
Gemfile

@@ -2,7 +2,7 @@
 
 source 'https://rubygems.org'
 
-gem 'leanweb', '~> 0.3.0'
+gem 'leanweb', '~> 0.4'
 gem 'haml', '~> 5.2.2'
 gem 'redcarpet'
 gem 'tilt-emacs_org'

+ 6 - 6
Gemfile.lock

@@ -4,19 +4,19 @@ GEM
     haml (5.2.2)
       temple (>= 0.8.0)
       tilt
-    leanweb (0.3.0)
+    leanweb (0.4.1)
       rack (~> 2.2.4)
       tilt (~> 2.0.11)
     nio4r (2.5.8)
-    nokogiri (1.13.8-x86_64-linux)
+    nokogiri (1.13.9-x86_64-linux)
       racc (~> 1.4)
-    puma (5.6.5)
+    puma (6.0.0)
       nio4r (~> 2.0)
     racc (1.6.0)
     rack (2.2.4)
     rake (13.0.6)
     redcarpet (3.5.1)
-    temple (0.8.2)
+    temple (0.9.1)
     tilt (2.0.11)
     tilt-emacs_org (0.1.1)
       nokogiri (~> 1.13.7)
@@ -27,11 +27,11 @@ PLATFORMS
 
 DEPENDENCIES
   haml (~> 5.2.2)
-  leanweb (~> 0.3.0)
+  leanweb (~> 0.4)
   puma
   rake
   redcarpet
   tilt-emacs_org
 
 BUNDLED WITH
-   2.3.22
+   2.3.23

BIN
public/2022/11/afiche.png


BIN
public/2022/11/thumb-afiche.jpg


+ 23 - 0
public/assets/layout.css

@@ -70,3 +70,26 @@ small {
     color: #888;
     font-size: 0.8em;
 }
+
+.form-field {
+    margin: 0 auto 1rem;
+}
+
+.form-field input[type=text],
+.form-field input[type=email] {
+    min-width: 300px;
+}
+
+.form-field textarea {
+    width: 300px;
+    height: 100px;
+}
+
+.inline > * {
+    display: inline !important;
+}
+
+.required:after {
+    content: ' *';
+    color: red;
+}

+ 11 - 46
routes.rb

@@ -1,51 +1,16 @@
 # frozen_string_literal: true
 
 ROUTES = [
+  { path: '/' },
+  { path: '/nosotros.html' },
+  { path: '/sign', method: 'POST' },
+  { path: '/signup', method: 'POST' },
+  { path: '/2022/01/propuestas-constitucionales.html' },
+  { path: '/2022/02/presentacion-convencion-constitucional.html' },
+  { path: '/2022/09/rescate-proceso-constituyente.html' },
+  { path: '/2022/10/vulnerabilidades-informaticas-estado-chile.html' },
   {
-    path: '/',
-    action: -> { render_with_layout('index.haml', title: 'Documentos') }
-  },
-  {
-    path: '/2022/01/propuestas-constitucionales.html',
-    action: lambda do
-      render_with_layout(
-        '2022_01-propuestas_constitucionales.haml',
-        title: 'Propuestas constitucionales'
-      )
-    end
-  },
-  {
-    path: '/2022/02/presentacion-convencion-constitucional.html',
-    action: lambda do
-      render_with_layout(
-        '2022_02-presentacion_convencion_constitucional.haml',
-        title: 'Presentación Convención Constitucional'
-      )
-    end
-  },
-  {
-    path: '/2022/09/rescate-proceso-constituyente.html',
-    action: lambda do
-      render_with_layout(
-        '2022_09-rescate_proceso_constituyente.org',
-        options: { setupfile: 'setup.org' }
-      )
-    end
-  },
-  {
-    path: '/2022/10/vulnerabilidades-informaticas-estado-chile.html',
-    action: lambda do
-      render_with_layout(
-        '2022_10-vulnerabilidades.md',
-        title: 'Sobre vulnerabilidades informáticas en el Estado de Chile'
-      )
-    end
-  },
-  {
-    path: '/nosotros.html',
-    action: lambda do
-      render_with_layout('nosotros.md', title: 'Acerca de nosotros')
-    end
-  },
-  { path: '/sign', method: 'POST' }
+    path: '/aaron-swartz-2022',
+    action: -> { render_with_layout('2022/11/aaron-swartz.haml') }
+  }
 ].freeze

+ 40 - 1
src/controllers/main_controller.rb

@@ -14,8 +14,27 @@ class MainController < LeanWeb::Controller
     render_with_layout('sign.haml')
   end
 
+  def signup_post
+    return render_with_layout('signup_error.haml') if
+      any_param_empty?(%w[subject name email]) ||
+      !params['challenge'].empty?
+
+    mail_signup
+    render_with_layout('signup.haml')
+  end
+
   protected
 
+  def any_param_empty?(param_keys)
+    return true if params.nil?
+
+    param_keys.each do |param|
+      return true if !params.include?(param) || params[param].empty?
+    end
+
+    false
+  end
+
   def valid_sign_params?
     params['challenge'].empty? && !params['email'].empty? &&
       (!params['name'].empty? || !params['org'].empty?)
@@ -37,7 +56,27 @@ class MainController < LeanWeb::Controller
     )
   end
 
+  def mail_signup
+    require 'lean_mail'
+    LeanMail.deliver(
+      # ENV.fetch('NOTIFICATION_EMAILS').split,
+      'root@solucioneslibres.com',
+      "Inscripción para #{params['subject']}",
+      <<~MAIL
+        Nombre o apodo: #{params['name']}
+        Email: #{params['email']}
+        Web o red social: #{params['web']}
+        Recibir emails: #{params&.[]('mailing_list') ? 'Sí' : 'No'}
+        Comentarios:
+        #{params['comments']}
+      MAIL
+    )
+  end
+
   def template_defaults
-    { 'md' => { with_toc_data: true } }
+    {
+      'md' => { with_toc_data: true },
+      'org' => { setupfile: 'setup.org' }
+    }
   end
 end

src/views/2022_01-propuestas_constitucionales.haml → src/views/2022/01/propuestas-constitucionales.haml


src/views/2022_02-presentacion_convencion_constitucional.haml → src/views/2022/02/presentacion-convencion-constitucional.haml


+ 0 - 0
src/views/2022_09-rescate_proceso_constituyente.org


Some files were not shown because too many files changed in this diff