Paul: Check-in [e440848497]

Online event coordination and survey application

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:feat: Begin to work on yes/no form
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:e44084849777bbde71ed1a59de962ba1419ae6af34338f1d76f82afcafd36a1f
User & Date: milouse 2018-10-21 21:57:39
Context
2018-10-22
08:09
feat: Add missing project files check-in: d929567a47 user: milouse tags: trunk
2018-10-21
21:57
feat: Begin to work on yes/no form check-in: e440848497 user: milouse tags: trunk
21:56
Add missing view Leaf check-in: 1ba0427cd2 user: milouse tags: integrate-coffee
16:30
feat: Check-in fossil related files check-in: 75ff306a0c user: milouse tags: trunk
Changes

Changes to .fossil-settings/ignore-glob.





1





node_modules

>
>
>
>

>
1
2
3
4
5
6
.ruby-gemset
.bundle
tmp/logs/application.log
tmp/pids/sinatra.pid
node_modules
public/paul.js*

Changes to assets/coffee/main.coffee.

1




2
3

4























5
6
7













document.addEventListener 'DOMContentLoaded', ->




  cp = document.getElementById('create_poll')
  return unless cp?

  cp.addEventListener 'submit', (event) ->























    event.preventDefault()
    event.stopPropagation()
    console.log '>>> working'













|
>
>
>
>
|
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

35
36
37
38
39
40
41
42
43
44
45
46
47
class YesNoPoll
  constructor: (@create_form) ->
    @template = @create_form.querySelector \
      '#survey_fields>div.form_group'
    return null unless @template?
    nb = document.getElementById('new_props')
    return null unless nb?
    @proposal_count = 1
    nb.addEventListener 'click', (event) ->
      currentYesNoPoll.insert_template()

  remove_template: (elem) ->
    console.log '>> elem', elem.parentElement

  insert_template: ->
    addProps = document.querySelector '#survey_fields>div.add_props'
    return false unless addProps?
    newProp = @template.cloneNode(true)
    prop = @proposal_count + 1
    label = newProp.querySelector('label')
    label.textContent = "Proposal #{prop}:"
    label.setAttribute('for', "props#{prop}field")
    input = newProp.querySelector('input')
    input.setAttribute('id', "props#{prop}field")
    input.value = ''
    input.required = false
    addProps.parentElement.insertBefore newProp, addProps
    remLink = document.createElement('input')
    remLink.type = 'button'
    remLink.value = '×'
    remLink.title = 'Remove proposal'
    remLink.addEventListener 'click', (event) ->
      event.preventDefault()
      event.stopPropagation()

      currentYesNoPoll.remove_template(event.target)
    newProp.appendChild remLink
    @proposal_count = prop

currentYesNoPoll = null
document.addEventListener 'DOMContentLoaded', ->
  cp = document.getElementById('create_poll')
  return unless cp?
  surveyType = document.querySelector(
    '#create_poll input[name=form_type]')
  return unless surveyType?
  if surveyType.value == 'yesno'
    currentYesNoPoll = new YesNoPoll(cp)

Changes to paul.rb.

1
2
3

4
5
6
7
8
9



10
11
12









13

14






















15
16
17
18
19
20
21
# frozen_string_literal: true

require 'sinatra/base'

require 'slim/smart'

# Main Sinatra application
class Paul < Sinatra::Base
  configure :production, :development do
    enable :logging



    disable :method_override, :sessions
  end










  def chdir

    Dir.chdir settings.root






















  end

  get '/' do
    @title = 'Paul'
    slim :index
  end




>






>
>
>



>
>
>
>
>
>
>
>
>
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# frozen_string_literal: true

require 'sinatra/base'
require 'logger'
require 'slim/smart'

# Main Sinatra application
class Paul < Sinatra::Base
  configure :production, :development do
    enable :logging
    app_logger = Logger.new("#{root}/tmp/logs/application.log")
    app_logger.datetime_format = '%Y-%m-%d %H:%M:%S'
    set :logger, app_logger
    disable :method_override, :sessions
  end

  configure :production do
    set :main_script_path, '/paul.js'
  end

  configure :development do
    set :main_script_path, 'http://localhost:8080/public/paul.js'
  end

  helpers do
    def logger
      if settings.respond_to?(:logger)
        settings.logger
      else
        request.logger
      end
    end
  end

  post '/create' do
    logger.info ">>>> params #{params.inspect}"
    @title = 'Survey created'
    slim :create
  end

  get '/date' do
    @title = 'Create a date poll'
    @form_type = :date
    slim :create
  end

  get '/yesno' do
    @title = 'Create a yes/no/maybe survey'
    @form_type = :yesno
    slim :create
  end

  get '/' do
    @title = 'Paul'
    slim :index
  end

Changes to public/style.css.

1
2
3




body {
    font-family: sans;
}







>
>
>
>
1
2
3
4
5
6
7
body {
    font-family: sans;
}

fieldset {
    border: 0px;
}

Added tmp/logs/.keep.

Added views/create.slim.













































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
form#create_poll method='post' action='/create'
  fieldset
    div.form_group
      label> for='titlefield' Title
      input#titlefield type='text' name='title' required=true
    div.form_group
      label> for='authorfield' Display name
      input#authorfield type='text' name='author' required=true
    div.form_group
      label
        input type='checkbox' name='maybe' value='yes'
        | Add a `maybe` option
    input type='hidden' name='form_type' value=@form_type
  fieldset#survey_fields
    div.form_group
      label> for='props1field' Proposal 1:
      input#props1field type='text' name='proposals[]' required=true
    div.add_props
      input#new_props type='button' value='Add a new proposal'
  fieldset
    div.form_group.submit
      input type='submit'

Changes to views/index.slim.



>
1
a href='yesno' Create a yes/no/maybe survey

Changes to views/layout.slim.

1
2
3
4
5

6
7
8
9
10
11
12
13
14
15
16
17
18
doctype html
html
  head
    title #{@title}
    link rel='stylesheet' href='/style.css' type='text/css'


  body
    #content
      h1 = @title

      == yield

      nav
        ul
          li
            License:
            a< href='http://www.wtfpl.net/txt/copying/' WTFPL
          li: a href='https://fossil.deparis.io/paul' Sources





>













1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
doctype html
html
  head
    title #{@title}
    link rel='stylesheet' href='/style.css' type='text/css'
    script type='text/javascript' src=settings.main_script_path

  body
    #content
      h1 = @title

      == yield

      nav
        ul
          li
            License:
            a< href='http://www.wtfpl.net/txt/copying/' WTFPL
          li: a href='https://fossil.deparis.io/paul' Sources