Exemplo n.º 1
0
def showFolder(path, fullPath):
  libView.doHeader("Documents: " + path)
  
  folderHeader()

  if(not os.path.exists(fullPath)):
    print "<p>Invalid path</p>"
  else:
    files = os.listdir(fullPath)
    for f in files:
      ff = os.path.join(fullPath, f)
      if(os.path.isdir(ff)):      
        libView.printf( "<p>Subdir: <a href=\"docs.py?path=%s%s/\">%s</a></p>", (toUrl(path), toUrl(f),toHtml(f),))

    for f in files:
      if(f != "meta.json"):
        ff = os.path.join(fullPath, f)
        if(not os.path.isdir(ff)):      
          libView.printf( "<p>File: <a href=\"docs.py?path=%s%s\">%s</a></p>", (toUrl(path), toUrl(f),toHtml(f),))

  meta = getMeta(path)
  meta["count"] = meta.get("count",0) + 1
  storeMeta(path, meta)
  
  libView.printf("<p>Folder has %d views</p>", meta["count"])
  if(1):
    print "<h2>Upload</h2>"
    print "<form action=\"docs.py\" enctype=\"multipart/form-data\" method=\"post\">"
    libView.printf("<input type=\"file\" name=\"uploaded_file\" max_size=\"%s\">", (80 * 1024*1024,))
    print "<input type=\"hidden\" name=\"action\" value=\"upload\">"
    libView.printf("<input type=\"hidden\" name=\"path\" value=\"%s\">", (toHtml(path),))
    if(0): # option to require mime-type declaration on upload (otherwise just ask user-agent)
      filetypes = ("text/plain", "image/jpeg", "image/png", "application/pdf")
      print "<select>"
      for filetype in filetypes:
        libView.printf("<option name=\"%s\">%s</option>", (toHtml(filetype), toHtml(filetype),))
      print "</select> "
    print "<input type=\"submit\" value=\"Upload\">"
    print "</form>"
  
  libView.doFooter();
Exemplo n.º 2
0
#!/usr/bin/env python
import libView;
libView.doHeader();

print "<p><a href='admin_defcon.py'>Defcon levels</a></p>";
print "<p><a href='admin_encryption.py'>Encryption</a></p>";
print "<p><a href='admin_backups.py'>Backups</a></p>";
print "<p><a href='admin_login.py'>Passwords</a></p>";
print "<p><a href='admin_logging.py'>Logging</a></p>";

libView.doFooter();
Exemplo n.º 3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import libView;
from libView import toHtml;
import cgi

# option to enable error-reports to remote browser
import cgitb
cgitb.enable()

libView.doHeader("Encoding test")

form = cgi.FieldStorage()
text = form.getvalue("text", "sample text")


print "<h2>Type some text to display</h2>"
print "<form action='test_encoding.py' method='post'>"
libView.printf("<input type=text name=text value=\"%s\">", (toHtml(text),))
print "<input type=submit value='OK'>"
print "</form>"

print "<p>You typed <span style='border:1px solid green; margin:2px; padding:2px;background-color:#CFC'>%s</span></p>" % (toHtml(text),)

URL = "test_encoding.py?text=" + libView.toUrl(text)
print "<p>URL would be %s <a href='%s'>Test</a></p>" % (URL, URL,)


libView.doFooter();
Exemplo n.º 4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import cgitb
cgitb.enable()

import libMain
import libView;
libView.doHeader(libMain.get("product"))

print "<p><a href=\"docs.py?path=/\">Documents</a></p>"
print "<p><a href=\"links.py\">Bookmarks</a></p>"

libView.doFooter();
Exemplo n.º 5
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import libView;
from libView import toHtml;
import cgi
import libData;
import re

# option to enable error-reports to remote browser
import cgitb
cgitb.enable()


form = cgi.FieldStorage()

libView.doHeader("Bookmarks")

bookmarks = libData.load("bookmarks")

accounts = bookmarks.get("accounts", {})

action = form.getvalue("action", "")

if(action == "add"):
  print "<h2>Import from another website</h2>"
  print "<form action=\"links.py\" method=\"post\">Import bookmarks from "
  print "<input type=\"hidden\" name=\"action\" value=\"import_webservice\" />"
  print "<select>"
  print "<option selected name=delicious>del.icio.us</option>"
  print "</select> "
  print "username <input type=text name=site_ac>"
Exemplo n.º 6
0
import libView
from libView import toHtml
import libDocs
import cgi
import os

form = cgi.FieldStorage()
path = form.getvalue("path", "/")
fullPath = libDocs.basePath() + path

if(not libDocs.validPath(path)):
  #---------------------------------------------------------
  # Invalid location
  #---------------------------------------------------------
  libView.doHeader("Documents")
  print "<p>Invalid path</p>"
  libView.doFooter();
elif(not path.endswith("/")):
  #---------------------------------------------------------
  # Displaying a file
  #---------------------------------------------------------
  libDocs.showFile(fullPath)
else:
  #---------------------------------------------------------
  # Displaying a folder
  #---------------------------------------------------------
  if(form.has_key("uploaded_file")):
    #---------------------------------------------------------
    # Upload
    #---------------------------------------------------------