<commit_before>################################
# Author:  <NAME> #
# Licence: CC-by-sa 3.0        #
#          see Licence         #
################################

require "hash"
require "yaml"

class Poll
	attr_reader :head, :name, :hidden
	YESVAL   = "ayes"
	MAYBEVAL = "bmaybe"
	NOVAL    = "cno"
	def initialize name
		@name = name
		@hidden = false
		@head = {}
		@data = {}
		@comment = []
		store "Poll #{name} created"
	end
	def sort_data fields
		if fields.include?("name")
			until fields.pop == "name"
			end
			@data.sort{|x,y|
				cmp = x[1].compare_by_values(y[1],fields) 
				cmp == 0 ? x[0] <=> y[0] : cmp
			}
		else
			@data.sort{|x,y| x[1].compare_by_values(y[1],fields) }
		end
	end
	def head_to_html
		ret = "<tr><th><a href='?sort=name'>Name</a></th>\n"
		@head.sort.each{|columntitle,columndescription|
			ret += "<th title='#{columndescription}'><a href='?sort=#{columntitle}'>#{columntitle}</a></th>\n"
		}
		ret += "<th><a href='.'>Last Edit</a></th>\n"
		ret += "</tr>\n"
		ret
	end
	def to_html(config = false)
		ret = "<table border='1'>\n"

		ret += head_to_html
		sort_data($cgi.include?("sort") ? $cgi.params["sort"] : ["timestamp"]).each{|participant,poll|
			ret += "<tr>\n"
			ret += "<td class='name' #{$cgi["edit"] == participant ? "id='active'":""}>"
			ret += participant
			ret += " <sup><a href='?edit=#{CGI.escape(participant)}'>edit</a></sup>"
			ret += "</td>\n"
			@head.sort.each{|columntitle,columndescription|
				klasse = poll[columntitle]
				case klasse 
				when nil
					value = UNKNOWN
					klasse = "undecided"
				when YESVAL
					value = YES
				when NOVAL
					value = NO
				when MAYBEVAL
					value = MAYBE
				end
				ret += "<td class='#{klasse}' title='#{participant}: #{columntitle}'>#{value}</td>\n"
			}
			ret += "<td class='date'>#{poll['timestamp'].strftime('%d.%m, %H:%M')}</td>"
			ret += "</tr>\n"
		}

		# PARTICIPATE<commit_msg>do not show edit button in config mode<commit_after>################################
# Author:  <NAME> #
# Licence: CC-by-sa 3.0        #
#          see Licence         #
################################

require "hash"
require "yaml"

class Poll
	attr_reader :head, :name, :hidden
	YESVAL   = "ayes"
	MAYBEVAL = "bmaybe"
	NOVAL    = "cno"
	def initialize name
		@name = name
		@hidden = false
		@head = {}
		@data = {}
		@comment = []
		store "Poll #{name} created"
	end
	def sort_data fields
		if fields.include?("name")
			until fields.pop == "name"
			end
			@data.sort{|x,y|
				cmp = x[1].compare_by_values(y[1],fields) 
				cmp == 0 ? x[0] <=> y[0] : cmp
			}
		else
			@data.sort{|x,y| x[1].compare_by_values(y[1],fields) }
		end
	end
	def head_to_html
		ret = "<tr><th><a href='?sort=name'>Name</a></th>\n"
		@head.sort.each{|columntitle,columndescription|
			ret += "<th title='#{columndescription}'><a href='?sort=#{columntitle}'>#{columntitle}</a></th>\n"
		}
		ret += "<th><a href='.'>Last Edit</a></th>\n"
		ret += "</tr>\n"
		ret
	end
	def to_html(config = false)
		ret = "<table border='1'>\n"

		ret += head_to_html
		sort_data($cgi.include?("sort") ? $cgi.params["sort"] : ["timestamp"]).each{|participant,poll|
			ret += "<tr>\n"
			ret += "<td class='name' #{$cgi["edit"] == participant ? "id='active'":""}>"
			ret += participant
			ret += " <sup><a href='?edit=#{CGI.escape(participant)}'>edit</a></sup>" unless config
			ret += "</td>\n"
			@head.sort.each{|columntitle,columndescription|
				klasse = poll[columntitle]
				case klasse 
				when nil
					value = UNKNOWN
					klasse = "undecided"
				when YESVAL
					value = YES
				when NOVAL
					value = NO
				when MAYBEVAL
					value = MAYBE
				end
				ret += "<td class='#{klasse}' title='#{participant}: #{columntitle}'>#{value}</td>\n"
			}
			ret += "<td class='date'>#{poll['timestamp'].strftime('%d.%m, %H:%M')}</td>"
			ret += "</tr>\n"
		}

		# PARTICIPATE
{'fraction_non_alphanumeric': 0.2379838919199792, 'fraction_numerical': 0.005196154845414394, 'mean_word_length': 3.375, 'pattern_counts': {'":': 2, '<': 61, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7256890', 'n_tokens_mistral': 1720, 'n_tokens_neox': 1489, 'n_words': 290}