diff options
-rwxr-xr-x | sources/projects/parse.rb | 29 | ||||
-rw-r--r-- | sources/projects/pre.sql | 2 | ||||
-rw-r--r-- | web/lib/ui/taginfo.rb | 14 | ||||
-rw-r--r-- | web/public/img/error.png | bin | 0 -> 937 bytes | |||
-rw-r--r-- | web/views/taginfo/project_error_log.erb | 8 | ||||
-rw-r--r-- | web/views/taginfo/projects.erb | 9 |
6 files changed, 58 insertions, 4 deletions
diff --git a/sources/projects/parse.rb b/sources/projects/parse.rb index 679d9de..1dcbfda 100755 --- a/sources/projects/parse.rb +++ b/sources/projects/parse.rb @@ -40,8 +40,10 @@ projects = db.execute("SELECT id, fetch_json FROM projects WHERE status='OK' ORD projects.each do |id, json| puts " #{id}..." + error_log = '' begin data = JSON.parse(json, { :symbolize_names => true, :create_additions => false }) + db.transaction do |db| db.execute("UPDATE projects SET data_format=?, data_url=? WHERE id=?", data[:data_format], data[:data_url], id) @@ -51,6 +53,27 @@ projects.each do |id, json| if data[:project] p = data[:project] + + if ! p[:name] + error_log += "ERROR: MISSING project.name\n" + end + + if ! p[:description] + error_log += "ERROR: MISSING project.description\n" + end + + if ! p[:project_url] + error_log += "ERROR: MISSING project.project_url\n" + end + + if ! p[:contact_name] + error_log += "ERROR: MISSING project.contact_name\n" + end + + if ! p[:contact_email] + error_log += "ERROR: MISSING project.contact_email\n" + end + db.execute("UPDATE projects SET name=?, description=?, project_url=?, doc_url=?, icon_url=?, contact_name=?, contact_email=? WHERE id=?", p[:name], p[:description], @@ -61,6 +84,8 @@ projects.each do |id, json| p[:contact_email], id ) + else + error_log += "ERROR: MISSING project\n" end if data[:tags] @@ -86,7 +111,11 @@ projects.each do |id, json| on['area'], ); end + else + error_log += "ERROR: MISSING tags\n" end + + db.execute("UPDATE projects SET error_log=? WHERE id=?", error_log, id) end rescue JSON::ParserError db.execute("UPDATE projects SET status='PARSE_ERROR' WHERE id=?", id) diff --git a/sources/projects/pre.sql b/sources/projects/pre.sql index ae55fbf..6f521cd 100644 --- a/sources/projects/pre.sql +++ b/sources/projects/pre.sql @@ -18,10 +18,10 @@ CREATE TABLE projects ( fetch_status TEXT, -- HTTP status code fetch_json TEXT, -- HTTP body status TEXT, -- 'OK', 'FETCH ERROR', 'PARSE ERROR' + error_log TEXT, data_format INTEGER, data_updated DATE, data_url TEXT, - icon BLOB, name TEXT, description TEXT, project_url TEXT, diff --git a/web/lib/ui/taginfo.rb b/web/lib/ui/taginfo.rb index 2f7451b..702f6e7 100644 --- a/web/lib/ui/taginfo.rb +++ b/web/lib/ui/taginfo.rb @@ -111,9 +111,21 @@ class Taginfo < Sinatra::Base @section = 'taginfo' @section_title = t.taginfo.meta - @projects = @db.select("SELECT * FROM projects.projects ORDER BY name").execute(); + @projects = @db.select("SELECT * FROM projects.projects ORDER BY name").execute() erb :'taginfo/projects' end + get %r{/taginfo/projects/([a-z_]+)/error_log} do |id| + @title = "Error log for project #{h(id)}" + @section = 'taginfo' + @section_title = t.taginfo.meta + + @data = @db.select("SELECT name, error_log FROM projects.projects"). + condition("id = ?", id). + execute()[0] + + erb :'taginfo/project_error_log' + end + end diff --git a/web/public/img/error.png b/web/public/img/error.png Binary files differnew file mode 100644 index 0000000..474f63f --- /dev/null +++ b/web/public/img/error.png diff --git a/web/views/taginfo/project_error_log.erb b/web/views/taginfo/project_error_log.erb new file mode 100644 index 0000000..5417905 --- /dev/null +++ b/web/views/taginfo/project_error_log.erb @@ -0,0 +1,8 @@ +<div class="pre"> + <h1 class="section">Error log for project <%= h(@data['name']) %></h1> +</div> +<div class="box"> + <pre> +<%= h(@data['error_log']) %> + </pre> +</div> diff --git a/web/views/taginfo/projects.erb b/web/views/taginfo/projects.erb index bca034d..d889aeb 100644 --- a/web/views/taginfo/projects.erb +++ b/web/views/taginfo/projects.erb @@ -4,7 +4,7 @@ <tr> <th>Icon</th> <th>Project ID<br/>Project Name</th> - <th>Fetch Date<br/>Updated</th><th>Code</th><th>Res</th> + <th>Fetch Date<br/>Updated</th><th>Code</th><th>Status</th> <th>JSON URL<br/>Data URL</th><th>Fmt<br/>Vers</th> <th>Project URL<br/>Doc URL</th><th>Contact</th> <th>Description</th> @@ -23,7 +23,12 @@ <%= h(project['data_updated']) %> </td> <td class="tc<%= c %> nowrap"><%= h(project['fetch_status']) %></td> - <td class="tc<%= c %> nowrap"><%= h(project['status']) %></td> + <td class="tc<%= c %> nowrap"> + <%= h(project['status']) %></br> + <% if project['error_log'] != '' %> + <a href="projects/<%= project['id'] %>/error_log"><img src="/img/error.png" width="16" height="16" alt="ERROR" title="Show warnings/errors"/></a> + <% end %> + </td> <td class="<%= c %> nowrap"> <a href="<%= h(project['json_url']) %>"><%= h(project['json_url']) %></a><br/> <a href="<%= h(project['data_url']) %>"><%= h(project['data_url']) %></a> |