Esempio n. 1
0
def emitPage(webin):
  
  sess = webin.session;
  if sess==None:
    user = "";
  else:
    user = sess.user;
  txt = """
<head>
    <link rel="stylesheet" type="text/css" href="/css/imagestyle.css"/>
</head>


<body>
<script>var jQuery; // for commonJS compatability</script>
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
"""
  pageName = 'albums_for_image'
  if constants.compressJs:
    txt += cjsForPage(pageName)
  else:
    txt += jsForPage(pageName)
  txt += """
<script>
idv.loggedInUser='******'

$(document).ready(page.initialize);

</script>

"""
  return htmlResponse(txt)
Esempio n. 2
0
def emitSnapPage(webin, parsedPath, parsedQuery, forHomePage):
    #print "PPPP",parsedPath
    #this is only used for debugging
    nm = parsedPath.name[0:-1]
    tp = "/snap/" + "/".join(nm)
    print "TOPIC ", tp
    sn = snapm.SnapD(tp)
    otxt = sn.genPage(sendToS3=False, compressJs=False)
    #print "OTXT",otxt
    #snaps.closeStore(webin.pageStore)
    return htmlResponse(otxt)
Esempio n. 3
0
def emitPage(webin):
    Logr.log("page", "EMITTING GALLERY PAGE")
    sess = webin.session
    if sess == None:
        user = ""
    else:
        user = sess.user
    images = {}
    albums = {}

    pg0 = gen.pageHeader(webin, "imageDiver") + """
<body>
"""

    pageName = 'gallery'

    if constants.compressJs:
        pg0 += commonCjsInclude + cjsForPage("gallery") + toJsInclude(
            "/pages/gallery_data.js")
    else:
        pg0 += commonJsIncludes + toJsIncludes(
            jsFiles['gallery']) + toJsInclude("/pages/gallery_data.js")
    """
  
      pg0 +=  commonJsIncludes + jsForPage(pageName)

  if constants.compressJs:
    pg0 += constants.jsPreamble + constants.toJsInclude("/cjs/common.js") +  constants.toJsInclude("/cjs/gallery.js")
  else:
    pg0 +=  constants.commonJsIncludes + constants.toJsInclude("/pages/gallery.js")
  """
    pg0 += """

<script>
$(document).ready(function () {
  page.initialize({loggedInUser:'******'});

});

</script>
<div class="outerDiv">
  <div class="topDiv">
      <div class="topDivTop"></div>
     <div class="titleDiv">the depths of high-resolution images, annotated</div>
  </div>
</div>

</body>
</html>
"""

    return htmlResponse(pg0)
Esempio n. 4
0
def emitPage(webin):
    sess = webin.session
    if sess == None:
        user = ""
    else:
        user = sess.user

    pg0 = gen.pageHeader(webin,
                         "the depths of high resolution images, annotated",
                         facebook=False) + "<body>"
    pageName = 'images'
    if constants.compressJs:
        pg0 += commonCjsInclude + cjsForPage(pageName)
    else:
        pg0 += commonJsIncludes + jsForPage(pageName)
    """
  var loading = $('<div style="margin:40px"><center>LOADING...  <img src="/ajax-loader.gif"/></center></dir>');
page.loadingDiv = loading;
$('body').append(loading);
 """
    pg1 = """


idv.util.commonInit();
var jsonUrl = "/api/allImages"
idv.util.get(jsonUrl,function (rs) {
  var images = rs.value;
  $('document').ready(
    function () {
      page.initialize(images,loggedInUser,"all");
    });

});
 


</script>
</body>
</html>
"""
    otxt = pg0 + \
      "<script>" + \
       "var loggedInUser='******';\n"
    otxt += constants.emitConstants()
    otxt += pg1

    return htmlResponse(otxt)
Esempio n. 5
0
def emitPage(webin):

    sess = webin.session
    if sess == None:
        user = ""
    else:
        user = sess.user
    txt = """
<head>
    <link rel="stylesheet" type="text/css" href="/css/imagestyle.css"/>
</head>


<body>
<script>var jQuery; // for commonJS compatability</script>
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
"""
    pageName = 'upload_iframe'
    if constants.compressJs:
        txt += cjsForPage(pageName)
    else:
        txt += jsForPage(pageName)
    txt += """
<script>
idv.loggedInUser='******'

$(document).ready(initialize);

</script>


<form id="theForm" target="_self" enctype="multipart/form-data" action="/api/upload?id=333" method="post">
  <p>File: <input id="fileInput" style="color:white" type="file" name="file"/></p>
  <p id="errorP"></p>
  <p><input id ="theButton" type="button" value="Upload"></p>
</form>
</body>
</html>
"""
    return htmlResponse(txt)
Esempio n. 6
0
def emitAlbumPage(webin, parsedPath, parsedQuery, forHomePage):
    pageStore = {}
    import model.album
    album = model.album
    vprint("parsedQuery " + str(parsedQuery))
    vprint("emitAlbumPage")
    sess = webin.session
    if sess == None:
        user = ""
    else:
        user = sess.user

    qs = getattr(webin, "queryString", None)
    published = 0  # is this the published version?
    """
  now, if we're here its unpublished 
  if qs:
    qsp = urlparse.parse_qs(qs)
    published = 0 if qsp.get('unpublished',False) else 1
  """

    name = parsedPath.name
    Logr.log("newdb", str(name))
    if len(name) < 3:
        return gen.emitNotFound(webin)

        #return gen.genStaticPage(webin,"ImageDiver Message"," <center><b>404</b></center><p><center>No such page</center></p>");

    imowner = name[0]
    imname = name[1]
    albumname = name[2]
    albumTopic = "/album/" + imowner + "/" + imname + "/" + albumname
    imageTopic = "/image/" + imowner + "/" + imname
    if albumname == "-":
        albumD = "-"
    else:
        albumD = album.loadAlbumD(albumTopic, webin.pageStore)

    if not albumD:
        #todo add error page here
        return gen.genStaticPage(webin, "ImageDiver Message",
                                 "<center><b>No such album</b></center>")
    im = image.loadImageD(imageTopic, webin.pageStore)
    imHasAlbums = album.hasAlbums(
        imageTopic, user)  # does this user have albums on this image
    imDict = models.toDict(im, [
        "dimensions", "title", "name", "author", "year", "externalLink",
        "description", "owner", "topic", "tilingDepthBump", "zoomDepthBump",
        "source"
    ])

    if albumD == "-":
        ownerD = models.loadUserD(user, webin.pageStore)
        ownerName = getattr(ownerD, "name", None)

        options = {
            "imageD": imDict,
            "imageTopic": imageTopic,
            "loggedInUser": user,
            "ownerName": ownerName,
            "albumOwner": user,
            "published": False
        }
        otxt = genAlbumPage(options)
        return htmlResponse(otxt)

    #print "IMDICT ",imDict
    author = getattr(im, "author", None)
    if author == None:
        author = ""
    else:
        author = ", " + author
    ttl = getattr(im, "title", "")
    albowner = albumD.owner
    vprint("OWNER ", albowner, user)
    if (not constants.devVersion) and (albowner != user):
        return gen.genStaticPage(
            webin, "ImageDiver Message",
            "<center><b>This is an unpublished album</b></center>")

    beenPublished = getattr(albumD, "published", 0)
    vprint("beenPublished", beenPublished)
    ownerD = models.loadUserD(albowner, webin.pageStore)
    ownerName = getattr(ownerD, "name", None)
    apub = getattr(albumD, "published", None)
    if published and (not apub):
        return gen.genStaticPage(
            webin, "ImageDiver Message",
            "<center><b>This album has not yet been published</b></center>")

    #imageTopic = albumD.image
    #options = {"imageD":imDict,"albumOwner":albumD.owner,"albumOwnerName":ownerName,"loggedInUser":user,"hasAlbums":imHasAlbums,
    #          "albumTopic":albumD.topic,"published":published,"beenPublished":beenPublished,"path":"/"}

    options = {
        "imageD": imDict,
        "albumOwner": albumD.owner,
        "albumOwnerName": ownerName,
        "loggedInUser": user,
        "imTitle": ttl,
        "imAuthor": author,
        "albumTopic": albumD.topic,
        "imageTopic": imageTopic,
        "published": published,
        "beenPublished": beenPublished,
        "path": webin.path
    }
    vprint("OPTIONS", options)
    otxt = genAlbumPage(options)
    #snaps.closeStore(webin.pageStore)

    return htmlResponse(otxt)
Esempio n. 7
0
def emitAlbumPage(webin,parsedPath,parsedQuery,forHomePage):
  a = album.AlbumD()
  otxt = a.genPage()
  #snaps.closeStore(webin.pageStore)

  return  htmlResponse(otxt)