Method: Web#create_category_graph
- Defined in:
- app/models/web.rb
#create_category_graph(prog, show_authors, selected_categories, mm_size) ⇒ Object
{{{
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'app/models/web.rb', line 208 def create_category_graph(prog, , selected_categories, mm_size) #{{{ dotFile = File.("#{WikiService.storage_path}/graph.dot") mapFile = File.("#{WikiService.storage_path}/graph.map") pngFile = File.("#{WikiService.storage_path}/map.png") File.open(dotFile, "w") do |file| # Graph properties: output_graph_header_to file, mm_size # Page Special nodes properties: categs = selected_categories.empty? ? categories : selected_categories categs.each do |category| file.puts %{"#{category}" [fontsize=20,style=filled,color=grey,comment="#{category}",URL="../list/?category=#{category}"];} end # Links and node properties: nodes = filter_categories(pages.values, selected_categories) auths = # avoid repeated selects unless nodes.delete_if { |entry| auths.include? entry.name } end nodes.each do |page| file.puts %{"#{page.plain_name}" [URL=\"../show/#{page.name}\"];} page.categories.each do |category| file.puts %{"#{category}" -> "#{page.plain_name}";} end end file end call_graphviz(prog, dotFile, mapFile, pngFile) [pngFile, mapFile] end |