stocked
Daniel Asher Resnick 2 years ago
parent e6d89e11a7
commit ffd5dc4d77
  1. 3
      Gemfile
  2. 2
      Gemfile.lock
  3. 11
      src/app.rb
  4. 11
      src/public/css/stocked.css
  5. 2030
      src/public/js/stocked.js
  6. 1796
      src/public/js/stocked/test/data-archive.js
  7. 23
      src/public/js/stocked/test/data_1.json
  8. 56
      src/views/partials/stocked.erb

@ -5,7 +5,8 @@ gem 'sinatra'
gem 'sinatra-contrib' gem 'sinatra-contrib'
gem 'prawn', '2.2.2' gem 'prawn', '2.2.2'
gem 'prawn-templates', '0.1.1' gem 'prawn-templates', '0.1.1'
gem 'rubyzip'
group :development do group :development do
gem 'rerun' gem 'rerun'
end end

@ -37,6 +37,7 @@ GEM
listen (~> 3.0) listen (~> 3.0)
ruby-rc4 (0.1.5) ruby-rc4 (0.1.5)
ruby_dep (1.5.0) ruby_dep (1.5.0)
rubyzip (2.3.2)
sinatra (2.0.5) sinatra (2.0.5)
mustermann (~> 1.0) mustermann (~> 1.0)
rack (~> 2.0) rack (~> 2.0)
@ -63,6 +64,7 @@ DEPENDENCIES
prawn (= 2.2.2) prawn (= 2.2.2)
prawn-templates (= 0.1.1) prawn-templates (= 0.1.1)
rerun rerun
rubyzip
sinatra sinatra
sinatra-contrib sinatra-contrib
thin thin

@ -123,6 +123,17 @@ post '/wiki' do
"/get_file?file=#{key}&download_name=#{data['name']} Character Sheet.wiki" "/get_file?file=#{key}&download_name=#{data['name']} Character Sheet.wiki"
end end
post '/stocked_download' do
request.body.rewind
raw = request.body.readpartial(16 * 1024)
puts raw
data = JSON.parse(raw)
key = "stock-#{Time.now.strftime('%Y%m%d%H%M%S%L')}-#{rand(1...10000)}"
CACHE.store key, data
"/get_file?file=#{key}&download_name=#{data['Name']}.stock"
end
get '/get_file' do get '/get_file' do
data = nil data = nil
if params['download_name'].match(/\.pdf$/) if params['download_name'].match(/\.pdf$/)

@ -48,9 +48,10 @@ div.skill-even {
div.skill-odd { div.skill-odd {
background: #F5F5F5; background: #F5F5F5;
} }
div.trait-even { tr.trait-even {
background: lightgray;
} }
div.trait-odd { tr.trait-odd {
background: #F5F5F5; background: #F5F5F5;
} }
textarea.trait-desc { textarea.trait-desc {
@ -58,3 +59,9 @@ textarea.trait-desc {
width: 98%; width: 98%;
margin: 1em; margin: 1em;
} }
table.traits{
width: 100%;
}
table.traits input.editable-name {
width: 100%;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,23 @@
{
"Foo Setting": {
"Born Foo": {
"time": 1,
"res": 5,
"stat": [
[1, "pm"]
],
"leads": [
"Bar"
],
"key_leads": [
"Bar Setting"
],
"skills": [
[3, "General"]
],
"traits": [1],
"common_traits": []
}
},
"Bar Setting": {}
}

@ -29,13 +29,14 @@
<div class='container'> <div class='container'>
<div class='row'> <div class='row'>
<div class='col-md-3'> <div class='col-md-3'>
<a href='' ng-click='stocked_uploadCharredModel()'> <input type="file" id="stocked_charred_file"/>
TODO: Upload charred model <a href='' ng-click='stocked_loadCharredModel()'>
TODO: Load charred stock model
</a> </a>
</div> </div>
<div class='col-md-3'> <div class='col-md-3'>
<a href='' ng-click='stocked_downloadCharredModel()'> <a href='' ng-click='stocked_downloadCharredModel()'>
TODO: Download charred model TODO: Download charred stock model
</a> </a>
</div> </div>
<div class='col-md-3'> <div class='col-md-3'>
@ -113,6 +114,13 @@
<div class='panel-body'> <div class='panel-body'>
<div class="panel"> <div class="panel">
<div class="panel-body"> <div class="panel-body">
<span class="note-label">Note:</span>
<span class="note-content">
Prefix a lifepath's name with "Born " to have charred consider it a born lifepath;
i.e. selectable if and only if it is the first lifepath.
</span>
<br />
<a ng-click='collapseBody(".collapse_all_"+to_id(setting.name), $event)' href=''> <a ng-click='collapseBody(".collapse_all_"+to_id(setting.name), $event)' href=''>
collapse/expand all paths in setting collapse/expand all paths in setting
</a> </a>
@ -329,37 +337,41 @@
</div> </div>
<div class='panel-collapse collapse in' id='collapse_traits'> <div class='panel-collapse collapse in' id='collapse_traits'>
<div class='panel-body'> <div class='panel-body'>
<div class='container-fluid'> <table class="traits">
<div class='row'> <tr>
<div class='h4 col-md-3'>Trait</div> <th>Trait</th>
<div class='h4 col-md-1'>Cost</div> <th>Cost</th>
<div class='h4 col-md-2'>Type</div> <th>Type</th>
<%# <div class='h4 col-md-2'>Bonus</div> %> <%# <div class='h4 col-md-2'>Bonus</div> %>
<%# <div class='h4 col-md-2'>Restrictions</div> %> <%# <div class='h4 col-md-2'>Restrictions</div> %>
</div> </tr>
</div> <%# </div> %>
<div ng-repeat='trait in traits' ng-class-even="'trait-even'" ng-class-odd="'trait-odd'"> <tr ng-repeat-start='trait in traits' ng-class-even="'trait-even'" ng-class-odd="'trait-odd'">
<div class='row'> <td>
<div class='h4 col-md-3'>
<input ng-model="trait.name" <input ng-model="trait.name"
class='form-control input-lg not-editing editable-name' class='form-control input-lg not-editing editable-name'
ng-click="$event.stopPropagation()" ng-click="$event.stopPropagation()"
ng-focus='editField($event, true)' ng-blur='editField($event, false)' /> ng-focus='editField($event, true)' ng-blur='editField($event, false)' />
</div> </td>
<div class='h4 col-md-1'> <td>
<input type="number" class='not-editing editable-num' <input type="number" class='not-editing editable-num'
ng-model="trait.cost" ng-click="$event.stopPropagation()" ng-model="trait.cost" ng-click="$event.stopPropagation()"
ng-focus='editField($event, true)' ng-blur='editField($event, false)' /> ng-focus='editField($event, true)' ng-blur='editField($event, false)' />
</div> </td>
<div class='h4 col-md-2'> <td>
<select class='form-control' ng-model='trait.type' ng-options='t for t in TRAIT_TYPES'></select> <select class='form-control' ng-model='trait.type' ng-options='t for t in TRAIT_TYPES'></select>
</div> </td>
</div> <td><a href='' ng-click='removeTrait($index)'>[X]</a></td>
</tr>
<%# <div class='h4 col-md-2'>WISHLIST</div> %> <%# <div class='h4 col-md-2'>WISHLIST</div> %>
<%# <div class='h4 col-md-2'>WISHLIST</div> %> <%# <div class='h4 col-md-2'>WISHLIST</div> %>
<div> <tr ng-repeat-end ng-class-even="'trait-even'" ng-class-odd="'trait-odd'">
<textarea class='trait-desc' ng-model='trait.desc'></textarea> <td colspan="99"><textarea class='trait-desc' ng-model='trait.desc'></textarea></td>
</div> </tr>
</table>
<div class='row'>
<div class='h4 col-md-12'><a href='' ng-click='addTrait()'>Add new trait</a></div>
</div>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save