Skip to content

Commit

Permalink
counter
Browse files Browse the repository at this point in the history
  • Loading branch information
k1row committed Jan 3, 2013
1 parent a94d86b commit f2e9fe9
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified app/.DS_Store
Binary file not shown.
Binary file added app/controllers/.DS_Store
Binary file not shown.
19 changes: 19 additions & 0 deletions app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class SearchController < ApplicationController

@data = []
@error = false
@access_count = 0

def index
logger.debug "@@@ index @@@"
Expand All @@ -51,8 +52,26 @@ def index
logger.debug(@target_tag)
create_data
end
else
counter
end
end
def counter
file = "count.dat"
begin
fp = open(file, "r")
counter = fp.gets.to_i + 1
fp.close
rescue
counter = 1
end
@access_count = counter
logger.debug "@@@ access_count @@@"
logger.debug(@access_count)
fp = open(file, "w")
fp.print counter
fp.close
end
def create_data
logger.debug(@@base_url)
json = parse_json(@@base_url)
Expand Down
Binary file modified app/views/.DS_Store
Binary file not shown.
24 changes: 24 additions & 0 deletions app/views/search/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@
<div class="ad_frame sid_62056d310111552c1a8587de29171abe00e7b93dd4b39587f228691ad40d6932 container_div color_#0000CC-#000000-#999999-#0000FF-#009900 sp fit wv"></div>
↑↑↑ Advertisement is here ↑↑↑ <br>

<h1>What kind of photograph do you want to see ?</h1>
<form mothod="post" action="./index">
<input type="hidden" size="40" name="i" value="search" />
<input type="text" size="40" id="q" name="q"/>
<input type="submit" value="検索" />
</form>

<% if @data %>
<h2>You are looking for "<%= @target_tag %>" tag's photos.</h2>
<% @data.each do |data| %>
<%#= debug(data) %>
<a href="<%= data['link'] %>"><%= image_tag data['thumbnail'] %></a>
<% end %>
<% elsif @i == 'search' %>
<h2>Nothing ... such a tag's data</h2>
<% end %>
<%#= debug(@result) %>
<%#= debug(@request) %>

<script src='http://j.amoad.com/js/aa.js?link=${ADCLOUD_LINK_ENCODE}' type='text/javascript' charset='utf-8'></script>

<p>
あなたは<%= @access_count %>人目です
</p>
</body>
</html>
1 change: 1 addition & 0 deletions count.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0

0 comments on commit f2e9fe9

Please sign in to comment.