block and source views seperated

This commit is contained in:
Torsten Ruger 2015-07-31 19:42:34 +03:00
parent bdfafd17c8
commit 65d95de885
8 changed files with 63 additions and 35 deletions

View File

@ -0,0 +1,12 @@
module Main
class BlocksController < Volt::ModelController
def initialize *args
super(*args)
blocks = BlocksModel.new
page._blocks = blocks
@volt_app.interpreter.register_event(:instruction_changed, blocks)
end
end
end

View File

@ -14,15 +14,9 @@ module Main
def index
init_machine
init_blocks
init_source
end
private
def marker var
return "W" if var.is_a? String
var.class.name.split("::").last[0]
end
def init_machine
machine = Virtual.machine.boot
@ -33,16 +27,6 @@ module Main
@volt_app.interpreter.start machine.init
end
def init_blocks
blocks = BlocksModel.new
page._blocks = blocks
@volt_app.interpreter.register_event(:instruction_changed, blocks)
end
def init_source
sources = SourceModel.new
page._sources = sources
@volt_app.interpreter.register_event(:instruction_changed, sources)
end
# The main template contains a #template binding that shows another
# template. This is the path to that template. It may change based
# on the params._component, params._controller, and params._action values.

View File

@ -0,0 +1,12 @@
module Main
class SourcesController < Volt::ModelController
def initialize *args
super(*args)
sources = SourceModel.new
page._sources = sources
@volt_app.interpreter.register_event(:instruction_changed, sources)
end
end
end

View File

@ -0,0 +1,15 @@
<:Title>
blocks index
<:Body>
<div class="block-view">
<div>
<h4> {{page._method_name}} </h4>
<h4> Block: {{page._block_name}} </h4>
</div>
{{ page._blocks.each do |b| }}
<div class="{{b._class_name}}">
{{b._name}}
</div>
{{ end }}
</div>

View File

@ -7,26 +7,9 @@
<div class="file-view">
</div>
<div class="source-view">
<h4> Virtual Machine Instruction </h4>
{{page._sources.each do |source| }}
<div class="{{source._class_name}}">
{{source._name}}
</div>
{{end}}
</div>
<:sources />
<div class="block-view">
<div>
<h4> {{page._method_name}} </h4>
<h4> Block: {{page._block_name}} </h4>
</div>
{{ page._blocks.each do |b| }}
<div class="{{b._class_name}}">
{{b._name}}
</div>
{{ end }}
</div>
<:blocks />
<:status/>

View File

@ -0,0 +1,12 @@
<:Title>
sources index
<:Body>
<div class="source-view">
<h4> Virtual Machine Instruction </h4>
{{page._sources.each do |source| }}
<div class="{{source._class_name}}">
{{source._name}}
</div>
{{end}}
</div>

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe '', type: :feature do
# Specs here
end

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe '', type: :feature do
# Specs here
end