Referer cleanup
This commit is contained in:
		
							parent
							
								
									1e55f21fa5
								
							
						
					
					
						commit
						7bdf5b0f76
					
				| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
import tables, macros, strformat, xmltree
 | 
					import tables, macros, strformat, xmltree
 | 
				
			||||||
import karax/[karaxdsl, vdom, vstyles]
 | 
					import karax/[karaxdsl, vdom, vstyles]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import renderutils
 | 
				
			||||||
import ../types, ../prefs_impl
 | 
					import ../types, ../prefs_impl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
proc genCheckbox(pref, label: string; state: bool): VNode =
 | 
					proc genCheckbox(pref, label: string; state: bool): VNode =
 | 
				
			||||||
| 
						 | 
					@ -55,14 +56,11 @@ proc renderPreferences*(prefs: Prefs; path: string): VNode =
 | 
				
			||||||
  buildHtml(tdiv(class="preferences-container")):
 | 
					  buildHtml(tdiv(class="preferences-container")):
 | 
				
			||||||
    fieldset(class="preferences"):
 | 
					    fieldset(class="preferences"):
 | 
				
			||||||
      form(`method`="post", action="/saveprefs"):
 | 
					      form(`method`="post", action="/saveprefs"):
 | 
				
			||||||
        verbatim "<input name=\"referer\" style=\"display: none\" value=\"$1\"/>" % path
 | 
					        refererField path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        renderPrefs()
 | 
					        renderPrefs()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        button(`type`="submit", class="pref-submit"):
 | 
					        button(`type`="submit", class="pref-submit"):
 | 
				
			||||||
          text "Save preferences"
 | 
					          text "Save preferences"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      form(`method`="post", action="/resetprefs", class="pref-reset"):
 | 
					      buttonReferer "/resetprefs", "Reset Preferences", path, class="pref-reset"
 | 
				
			||||||
        verbatim "<input name=\"referer\" style=\"display: none\" value=\"$1\"/>" % path
 | 
					 | 
				
			||||||
        button(`type`="submit"):
 | 
					 | 
				
			||||||
          text "Reset preferences"
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,8 +39,18 @@ proc linkText*(text: string; class=""): VNode =
 | 
				
			||||||
  buildHtml():
 | 
					  buildHtml():
 | 
				
			||||||
    a(href=url, class=class): text text
 | 
					    a(href=url, class=class): text text
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					proc refererField*(path: string): VNode =
 | 
				
			||||||
 | 
					  buildHtml():
 | 
				
			||||||
 | 
					    verbatim "<input name=\"referer\" style=\"display: none\" value=\"$1\"/>" % path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
proc iconReferer*(icon, action, path: string, title=""): VNode =
 | 
					proc iconReferer*(icon, action, path: string, title=""): VNode =
 | 
				
			||||||
  buildHtml(form(`method`="get", action=action, class="icon-button")):
 | 
					  buildHtml(form(`method`="get", action=action, class="icon-button")):
 | 
				
			||||||
    verbatim "<input name=\"referer\" style=\"display: none\" value=\"$1\"/>" % path
 | 
					    refererField path
 | 
				
			||||||
    button(`type`="submit"):
 | 
					    button(`type`="submit"):
 | 
				
			||||||
      icon icon, title=title
 | 
					      icon icon, title=title
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					proc buttonReferer*(action, text, path: string; class=""; `method`="post"): VNode =
 | 
				
			||||||
 | 
					  buildHtml(form(`method`=`method`, action=action, class=class)):
 | 
				
			||||||
 | 
					    refererField path
 | 
				
			||||||
 | 
					    button(`type`="submit"):
 | 
				
			||||||
 | 
					      text text
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,10 +58,7 @@ proc renderVideoDisabled(video: Video; path: string): VNode =
 | 
				
			||||||
      of mp4:
 | 
					      of mp4:
 | 
				
			||||||
        p: text "mp4 playback disabled in preferences"
 | 
					        p: text "mp4 playback disabled in preferences"
 | 
				
			||||||
      of m3u8, vmap:
 | 
					      of m3u8, vmap:
 | 
				
			||||||
        form(`method`="post", action=("/enablehls")):
 | 
					        buttonReferer "/enablehls", "Enable hls playback", path
 | 
				
			||||||
          verbatim "<input name=\"referer\" style=\"display: none\" value=\"$1\"/>" % path
 | 
					 | 
				
			||||||
          button(`type`="submit"):
 | 
					 | 
				
			||||||
            text "Enable hls playback"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
proc renderVideoUnavailable(video: Video): VNode =
 | 
					proc renderVideoUnavailable(video: Video): VNode =
 | 
				
			||||||
  buildHtml(tdiv):
 | 
					  buildHtml(tdiv):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue