diff --git a/helpers.rb b/helpers.rb new file mode 100644 index 0000000..c4f9c3a --- /dev/null +++ b/helpers.rb @@ -0,0 +1,3 @@ +def link_to(label,url) + %{#{label}} +end \ No newline at end of file diff --git a/main.rb b/main.rb index ec9e2b8..c04e180 100644 --- a/main.rb +++ b/main.rb @@ -5,6 +5,7 @@ require 'sass' require 'logger' require 'yaml' +require 'helpers' Dir.glob(File.join(File.dirname(__FILE__), 'models/*.rb')).each {|f| require f } DBCONFIG = YAML.load_file('database.yml') unless defined?(DBCONFIG) @@ -40,16 +41,21 @@ end get '/' do - @word ||= Word.first(:lemma => 'hello') haml :index end post '/' do + redirect "word/#{params[:lemma]}" @word = Word.first(:lemma => params[:lemma]) haml :index end +get '/word/:lemma' do + @word = Word.first(:lemma => params[:lemma]) + haml :word +end + get '/stylesheets/style.css' do header 'Content-Type' => 'text/css; charset=utf-8' sass :style -end +end \ No newline at end of file diff --git a/views/index.haml b/views/index.haml index ad4ff42..057163b 100644 --- a/views/index.haml +++ b/views/index.haml @@ -1,23 +1,23 @@ -#wordnet-search - %form{:method => 'post'} - %input{:type=>'text', :size=>40, :name=>'lemma', :id=>'lemma_search'} - %input{:type =>'submit', :value=>'search'} - #content - %table.display - - @word.attributes.each_pair do |k,v| - %tr - %td{:class=>'title'}= k - %td= v - %p - - %table.display - -@word.synsets.each do |synset| - %tr - %td{:class=>'title'}= synset.categorydef.name - %td= synset.definition - -%script - :plain - document.getElementById('wordnet-search').focus(); +#wordnatra-info +Welcome to Wordnatra. +%br +Wordnatra is an interface to Princeton's "Wordnet" lexical dictionary. +%br +To get started, search for a word. +%p +For information on this project and the technologies used, see the following links: +%p + +=link_to 'Wordnatra', 'http://github.com/gnugeek/wordnatra/tree/master' +%br +=link_to 'Wordnet', 'http://wordnet.princeton.edu/' +%br +=link_to 'Ruby', 'http://www.ruby-lang.org/en/' +%br +=link_to 'MySQL', 'http://www.mysql.com/' +%br +=link_to 'Sinatra', 'http://sinatra.rubyforge.org/' +%br +=link_to 'DataMapper', 'http://datamapper.org/doku.php' \ No newline at end of file diff --git a/views/layout.haml b/views/layout.haml index 9508b2d..547e651 100644 --- a/views/layout.haml +++ b/views/layout.haml @@ -6,4 +6,16 @@ %body #banner Wordnatra %br - = yield \ No newline at end of file + + #wordnet-search + %form{:method => 'post', :action => '/'} + %input{:type=>'text', :size=>40, :name=>'lemma', :id=>'lemma_search'} + %input{:type =>'submit', :value=>'search'} + + %p + + = yield + +%script + :plain + document.getElementById('wordnet-search').focus(); diff --git a/views/word.haml b/views/word.haml new file mode 100644 index 0000000..c81b908 --- /dev/null +++ b/views/word.haml @@ -0,0 +1,12 @@ +%table.display + - @word.attributes.each_pair do |k,v| + %tr + %td{:class=>'title'}= k + %td= v +%p + +%table.display + -@word.synsets.each do |synset| + %tr + %td{:class=>'title'}= synset.categorydef.name + %td= synset.definition \ No newline at end of file