Commits

magicrebirth committed 4a219b8 Draft

new templates

Comments (0)

Files changed (13)

Binary file modified.
 from django.contrib import admin
 from django.conf import settings
 
-import utils.modelextra.mymodels as mymodels
+# fix for python 2.7: http://bugs.python.org/issue7902
+import myutils.modelextra.mymodels as mymodels
+# except:
+#     import apps.myutils.modelextra.mymodels as mymodels
 
 # import mptt
 

templates/frames/content.html

+<html>
+<head>
+<title>HTML Frames Example - Content</title>
+<style type="text/css">
+body {
+	font-family:verdana,arial,sans-serif;
+	font-size:10pt;
+	margin:30px;
+	background-color:whitesmoke;
+	}
+</style>
+</head>
+<body>
+<h1>Content</h1>
+<h2>Click on the links to see the website here</h2>
+<p>Clicking on any of the links on the left will open the new page within the current frame.</p>
+
+<h2>Replacing the Whole Frameset</h2>
+<p>When you click on another link, the whole frameset is replaced with the new website.</p>
+
+
+<h2>Open a New Window</h2>
+<p>In order to open the links in a new browser window, right-click on them and select 'open in a new window/tab'.</p>
+
+</body>
+</html>

templates/frames/index.html

+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
+<html>
+<head>
+<title>Links Navigator App</title>
+</head>
+<!--
+======================================================================================================
+This template is available for free download from the Quackit website.
+
+If you have found it to be useful, please consider linking from your website to http://www.quackit.com
+
+Thanks!
+======================================================================================================
+
+Note the following:
+1. Each frame has it's own 'frame' tag.
+2. Each frame has a name (eg, name="menu"). This is used for when you need to load one frame from another. For example, your left frame might have links that, when clicked on, loads a new page in the right frame. This is acheived by using 'target="content"' within your links/anchor tags.
+3. Each 'frame' tag has a 'src' attribute. This is where you specify the name of the file to be loaded into that frame when the page first loads.
+4. You can change the size of the frames by changing the value of the 'cols' and/or 'rows' attribute. A value of "200" sets the frame at 200 pixels. An asterisk (*) specifies that the frame should use up whatever space is left over from the other frames. You can also use percentage values if desired (i.e. 20%,80%)
+5. To specify a border, set 'frameborder' and 'border' to "1". I included both attributes for maximum browser compatibility.
+6. The 'framespacing' attribute doesn't work in all browsers, but you can set any numeric value you like here.
+7. To learn more about HTML frames, check out: http://www.quackit.com/html/tutorial/html_frames.cfm
+-->
+
+<frameset cols="200,*" frameborder="0" border="0" framespacing="0">
+	<frame name="menu" src="menu" marginheight="0" marginwidth="0" scrolling="auto" noresize>
+<frameset rows="100,*" frameborder="0" border="0" framespacing="0">
+  	<frame name="topNav" src="top_nav">
+	<frame name="content" src="content" marginheight="0" marginwidth="0" scrolling="auto" noresize>
+</frameset>
+
+<noframes>
+<p>This section (everything between the 'noframes' tags) will only be displayed if the users' browser doesn't support frames. You can provide a link to a non-frames version of the website here. Feel free to use HTML tags within this section.</p>
+</noframes>
+
+</frameset>
+</html>

templates/frames/left_menu.html

+<html>
+<head>
+<title>HTML Frames Example - Menu 1</title>
+<style type="text/css">
+body {
+	font-family:verdana,arial,sans-serif;
+	font-size:10pt;
+	margin:10px;
+	background-color:#ff9900;
+	}
+	a {
+		color: blue;
+	}
+	a:hover {
+		color: white;
+		background: darkblue;
+	}
+	a:active {
+		color: yellow;
+	}
+</style>
+</head>
+<body>
+
+<h3>{{topic}}</h3>
+<p><a href="{{randomitem.url}}" target="content">random link</a></p>
+
+<h4>More Examples:</h4>
+
+{% for l in items  %}
+<li style="padding: 5px;"><a href="{{l.url}}" target="content">{{l.name}}</a></li>
+{% endfor %}
+
+
+
+</body>
+</html>

templates/frames/top_nav.html

+<html>
+<head>
+<title>HTML Frames Example - Top Nav</title>
+<style type="text/css">
+body {
+	font-family:verdana,arial,sans-serif;
+	font-size:10pt;
+	margin:10px;
+	background-color:rgb(104,50,49);
+	color: yellowgreen;
+	}
+	a {
+		color: white;
+	}
+	a:hover {
+		color: grey;
+		background: white;
+	}
+</style>
+</head>
+<body>
+<h3>Links for category "{{category|upper}}"
+<span style="text-align: right; font-size: 50%;"><a href="/lina" target="_top">home</a></span>
+</h3>
+	
+<p>
+	Groups:
+	{% for t in topics  %}
+	<a href="?topic={{t}}" target="menu">{{t}}</a> {% if not forloop.last %}|{% endif %}
+	{% endfor %}
+	{# <a href="menu_1.html" target="menu">Menu 1</a> | <a href="menu_2.html" target="menu">Menu 2</a> #}
+</p>
+</body>
+</html>

templates/lina/fw-47-4-col/index.html

-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
-<title>Fixed Width CSS Layouts - 4 Column - fw-47-4-col</title>
-<link rel="stylesheet" type="text/css" href="main.css" />
-</head>
-
-<body>
-
-   <!-- Begin Wrapper -->
-   <div id="wrapper">
-   
-         <!-- Begin Header -->
-         <div id="header">
-		 
-		       This is the Header		 
-			   
-		 </div>
-		 <!-- End Header -->
-		 
-		 <!-- Begin Left Column -->
-		 <div id="leftcolumn">
-		 
-		       Left Column
-		 
-		 </div>
-		 <!-- End Left Column -->
-		 
-		 <!-- Begin Left Middle Column -->
-		 <div id="leftmiddle">
-		       
-               <a href="#">Download this CSS Layout</a>		 
-			   
-         </div>
-		 <!-- End Left Middle Column -->
-		 
-		 <!-- Begin Right Middle Column -->
-		 <div id="rightmiddle">
-		 
-		       Right Middle Column
-		 
-		 </div>
-		 <!-- End Right Middle Column -->
-		 
-		 <!-- Begin Right Column -->
-		 <div id="rightcolumn">
-		 
-		       Right Column
-		 
-		 </div>
-		 <!-- End Right Column -->
-		 
-		 <!-- Begin Footer -->
-		 <div id="footer">
-		       
-			   This is the Footer		
-			    
-	     </div>
-		 <!-- End Footer -->
-		 
-   </div>
-   <!-- End Wrapper -->
-   
-</body>
-</html>

templates/lina/fw-47-4-col/main.css

-/*
-      Created by Keith Donegan of Code-Sucks.com
-	  
-	  E-Mail: Keithdonegan@gmail.com
-	  
-	  You can do whatever you want with these layouts,
-	  but it would be greatly appreciated if you gave a link
-	  back to http://www.code-sucks.com
-	  
-*/
-
-* { padding: 0; margin: 0; }
-
-body {
- font-family: Arial, Helvetica, sans-serif;
- font-size: 13px;
-}
-#wrapper { 
- margin: 0 auto;
- width: 922px;
-}
-#header {
- color: #333;
- width: 900px;
- float: left;
- padding: 10px;
- border: 1px solid #ccc;
- height: 100px;
- margin: 10px 0px 5px 0px;
- background: #BD9C8C;
-}
-#leftcolumn { 
- color: #333;
- border: 1px solid #ccc;
- background: #E7DBD5;
- margin: 0px 5px 5px 0px;
- padding: 10px;
- height: 350px;
- width: 205px;
- float: left;
-}
-#leftmiddle { 
- color: #333;
- border: 1px solid #ccc;
- background: #F2F2E6;
- margin: 0px 5px 5px 0px;
- padding: 10px;
- height: 350px;
- width: 205px;
- float: left;
-}
-#rightmiddle { 
- color: #333;
- border: 1px solid #ccc;
- background: #E7DBD5;
- margin: 0px 5px 5px 0px;
- padding: 10px;
- height: 350px;
- width: 205px;
- float: left;
-}
-#rightcolumn { 
- color: #333;
- border: 1px solid #ccc;
- background: #F2F2E6;
- margin: 0px 0px 5px 0px;
- padding: 10px;
- height: 350px;
- width: 204px;
- float: left;
-}
-#footer { 
- width: 900px;
- clear: both;
- color: #333;
- border: 1px solid #ccc;
- background: #BD9C8C;
- margin: 0px 0px 10px 0px;
- padding: 10px;
-}

templates/lina/linkslist.html

-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
- "http://www.w3.org/TR/html4/strict.dtd"> 
-<html>
-
-<head>
-	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
-	<title>{{category|capfirst}} Links</title>
-	
-	<style type="text/css" media="screen">
-	/*
-	      Created by Keith Donegan of Code-Sucks.com
-
-		  E-Mail: Keithdonegan@gmail.com
-
-		  You can do whatever you want with these layouts,
-		  but it would be greatly appreciated if you gave a link
-		  back to http://www.code-sucks.com
-
-	*/
-
-	* { padding: 0; margin: 0; }
-
-	body {
-	 font-family: Arial, Helvetica, sans-serif;
-	 font-size: 13px;
-	}
-	#wrapper { 
-	 margin: 0 auto;
-	 width: 1024px;
-	}
-	#header {
-	 color: #333;
-	 width: 1002px;
-	 float: left;
-	 padding: 10px;
-	 border: 1px solid #ccc;
-	 height: 100px;
-	 margin: 10px 0px 5px 0px;
-	 background: #BD9C8C;
-	}
-	#leftcolumn { 
-	 color: #333;
-	 border: 1px solid #ccc;
-	 background: #E7DBD5;
-	 margin: 0px 5px 5px 0px;
-	 padding: 10px;
-	 height: 350px;
-	 width: 230px;
-	 overflow: auto;
-	 float: left;
-	}
-	#leftmiddle { 
-	 color: #333;
-	 border: 1px solid #ccc;
-	 background: #F2F2E6;
-	 margin: 0px 5px 5px 0px;
-	 padding: 10px;
-	 height: 350px;
-	 width: 230px;
-	overflow: auto;
-	 float: left;
-	}
-	#rightmiddle { 
-	 color: #333;
-	 border: 1px solid #ccc;
-	 background: #E7DBD5;
-	 margin: 0px 5px 5px 0px;
-	 padding: 10px;
-	 height: 350px;
-	 width: 230px;
-	overflow: auto;
-	 float: left;
-	}
-	#rightcolumn { 
-	 color: #333;
-	 border: 1px solid #ccc;
-	 background: #F2F2E6;
-	 margin: 0px 0px 5px 0px;
-	 padding: 10px;
-	 height: 350px;
-	 width: 230px;
-	overflow: auto;
-	 float: left;
-	}
-	#footer { 
-	 width: 1002px;
-	 clear: both;
-	 color: #333;
-	 border: 1px solid #ccc;
-	 background: #BD9C8C;
-	 margin: 0px 0px 10px 0px;
-	 padding: 10px;
-	}
-	
-	
-	li{ line-height: 20px;}
-	li a:hover{background: white;}
-	h4 {margin-bottom: 10px;}
-	
-	</style>
-	
-</head>
-
-
-<body id="index" onload="">
-
-   <!-- Begin Wrapper -->
-   <div id="wrapper">
-   
-         <!-- Begin Header -->
-         <div id="header">
-		 
-		    <small><a href="{{subpath}}/lina" target="_parent">back</a></small>&nbsp;&nbsp;
-			<small><a href="{% if randomitem %}{{ randomitem.url }}{% endif %}" target="showframe">random</a></small>
-			<br /><br />
-			<h2>{{category|upper}}</h2>		 
-			   
-		 </div>
-		 <!-- End Header -->
-		 
-		
-		{% for item in items  %}
-			
-			<div id="{% cycle "leftcolumn" "leftmiddle" "rightmiddle" "rightcolumn" %}">
-				<h4>{{ item.0|capfirst|default:'unclassified' }}</h4>
-				{% for v in item.1  %}
-					<li><a href="{{v.url}}" target="_blank">{{v.name}}</a></li>
-				{% endfor %}
-			</div>
-		{% endfor %}
-		
-				
-		
-		 
-		 <!-- Begin Footer -->
-		 <div id="footer">
-		       
-			    {{totitems}} links in total.			
-			    
-	     </div>
-		 <!-- End Footer -->
-		 
-   </div>
-   <!-- End Wrapper -->
-   
-</body>
-
-</html>

templates/lina/main.html

 		a {color: blue;}
 		a.link2 {color: darkblue;}
 		a:hover {color: white; background:blue;}
+		img {float: left; padding: 20px;}
 	</style>
 	
 </head> 
 <body> 
 
-<img src="http://farm8.staticflickr.com/7193/6935386089_e2a6eec9bc_m.jpg" width="203" height="240" alt="LiNa">
+<img src="http://farm8.staticflickr.com/7193/6935386089_e2a6eec9bc_m.jpg" width="150" height="180" alt="LiNa">
 
 <p style='font-size:20px;'><strong>LiNa</strong> is a Link Navigator app for <a class="link2" href="https://www.djangoproject.com/">Django</a>.</p> 
 <p style='font-size:20px;'>Very simple: save some hyperlinks, give them a category and (if you want) a topic. All done using django's built-in admin interface (ps: included there's also a bookmarklet that lets you save links while you browse the web): <p>Save the bookmarklet: <a style="background: red; color:white;" href="javascript:(function()%7Bjavascript:(function()%7Bvar%20POPUP_URL=%22http://127.0.0.1:8000/lina/addonthespot/%22;var%20text;try%7Btext=((window.getSelection&&window.getSelection())%7C%7C(document.getSelection&&document.getSelection())%7C%7C(document.selection&&document.selection.createRange&&document.selection.createRange().text));%7Dcatch(e)%7Btext=%22%22;%7Dvar%20url=encodeURIComponent(location.href);var%20title=encodeURIComponent(document.title);window.open(POPUP_URL+%22?sense=%22+text+%22&url=%22+url+%22&title=%22+title,%22myWindow%22,%22status%20=%201,%20height%20=%20500,%20width%20=%20850,%20resizable%20=%200%22);%7D)();%7D)();">Add to LiNa</a> (log in required!)</p>

templates/lina/xx_linkslist.html

+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd"> 
+<html>
+
+<head>
+	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+	<title>{{category|capfirst}} Links</title>
+	
+	<style type="text/css" media="screen">
+	/*
+	      Created by Keith Donegan of Code-Sucks.com
+
+		  E-Mail: Keithdonegan@gmail.com
+
+		  You can do whatever you want with these layouts,
+		  but it would be greatly appreciated if you gave a link
+		  back to http://www.code-sucks.com
+
+	*/
+
+	* { padding: 0; margin: 0; }
+
+	body {
+	 font-family: Arial, Helvetica, sans-serif;
+	 font-size: 13px;
+	}
+	#wrapper { 
+	 margin: 0 auto;
+	 width: 1024px;
+	}
+	#header {
+	 color: #333;
+	 width: 1002px;
+	 float: left;
+	 padding: 10px;
+	 border: 1px solid #ccc;
+	 height: 100px;
+	 margin: 10px 0px 5px 0px;
+	 background: #BD9C8C;
+	}
+	#leftcolumn { 
+	 color: #333;
+	 border: 1px solid #ccc;
+	 background: #E7DBD5;
+	 margin: 0px 5px 5px 0px;
+	 padding: 10px;
+	 height: 350px;
+	 width: 230px;
+	 overflow: auto;
+	 float: left;
+	}
+	#leftmiddle { 
+	 color: #333;
+	 border: 1px solid #ccc;
+	 background: #F2F2E6;
+	 margin: 0px 5px 5px 0px;
+	 padding: 10px;
+	 height: 350px;
+	 width: 230px;
+	overflow: auto;
+	 float: left;
+	}
+	#rightmiddle { 
+	 color: #333;
+	 border: 1px solid #ccc;
+	 background: #E7DBD5;
+	 margin: 0px 5px 5px 0px;
+	 padding: 10px;
+	 height: 350px;
+	 width: 230px;
+	overflow: auto;
+	 float: left;
+	}
+	#rightcolumn { 
+	 color: #333;
+	 border: 1px solid #ccc;
+	 background: #F2F2E6;
+	 margin: 0px 0px 5px 0px;
+	 padding: 10px;
+	 height: 350px;
+	 width: 230px;
+	overflow: auto;
+	 float: left;
+	}
+	#footer { 
+	 width: 1002px;
+	 clear: both;
+	 color: #333;
+	 border: 1px solid #ccc;
+	 background: #BD9C8C;
+	 margin: 0px 0px 10px 0px;
+	 padding: 10px;
+	}
+	
+	
+	li{ line-height: 20px;}
+	li a:hover{background: white;}
+	h4 {margin-bottom: 10px;}
+	
+	</style>
+	
+</head>
+
+
+<body id="index" onload="">
+
+   <!-- Begin Wrapper -->
+   <div id="wrapper">
+   
+         <!-- Begin Header -->
+         <div id="header">
+		 
+		    <small><a href="{{subpath}}/lina" target="_parent">back</a></small>&nbsp;&nbsp;
+			<small><a href="{% if randomitem %}{{ randomitem.url }}{% endif %}" target="showframe">random</a></small>
+			<br /><br />
+			<h2>{{category|upper}}</h2>		 
+			   
+		 </div>
+		 <!-- End Header -->
+		 
+		
+		{% for item in items  %}
+			
+			<div id="{% cycle "leftcolumn" "leftmiddle" "rightmiddle" "rightcolumn" %}">
+				<h4>{{ item.0|capfirst|default:'unclassified' }}</h4>
+				{% for v in item.1  %}
+					<li><a href="{{v.url}}" target="_blank">{{v.name}}</a></li>
+				{% endfor %}
+			</div>
+		{% endfor %}
+		
+				
+		
+		 
+		 <!-- Begin Footer -->
+		 <div id="footer">
+		       
+			    {{totitems}} links in total.			
+			    
+	     </div>
+		 <!-- End Footer -->
+		 
+   </div>
+   <!-- End Wrapper -->
+   
+</body>
+
+</html>
 
 urlpatterns = patterns('lina.views',
 	url(r'^addonthespot/$', 'addonthespot', name='addonthespot'),
+	
 	url(r'^(?P<category>\w+)/(?P<frame>\w+)/$', 'main_view', name='main_view'),
+	
 	url(r'^(?P<category>\w+)/$', 'main_view', name='main_view'),
+	
 	url(r'^$', 'homepage', name='homepage'),
 	)
 	
 	SUBPATH = ""  # used if the application is mounted on a subdomain
 
 
-PUBLIC_CATEGORIES_HOMEPAGE = ['Journals', 'Jobs', 'Conferences']
+PUBLIC_CATEGORIES_HOMEPAGE = ['Journals', 'Conferences']
 
 # defines which categories should be ordered by date: not the best solutions, but it does the job for now
 CATEGORIES_ORDERED_BY_DATE = ['Conferences']
 
 
 
-def main_view(request, category):
+
+
+def main_view(request, category, frame=""):
 	""" This view handles requests for all components of the frame. 
 		If the frame name isn't passed, we assume we should return the framebase.html template.
 	"""
 
+	topic = request.GET.get('topic', "") 
 	temp, orderbydate, randomitem, finaldict, template_items = None, False, None, {}, []
+	if category.lower() in [x.lower() for x in CATEGORIES_ORDERED_BY_DATE]:
+		orderbydate = True
 	temp = _match_choice(category)
-	if temp:
-		if category.lower() in [x.lower() for x in CATEGORIES_ORDERED_BY_DATE]:
-			items = HyperLink.objects.filter(category=temp).order_by("-year")
-			totitems = items.count()
-			for i in items:
-				if finaldict.get(i.year):
-					finaldict[i.year] += [i]
-				else:
-					finaldict[i.year] = [i]
-			template_items = sorted(finaldict.items(), reverse=True)
+	context = {}
+	context['category'] = category
+	
+	if not temp:
+		return redirect('homepage')
+	
+	elif not frame: # it's the base frame structure
+		template = 'frames/index.html'
+									
+	elif topic or frame == "menu":
+		template = 'frames/left_menu.html'		
+		if orderbydate:
+			if not topic:
+				dates = HyperLink.objects.filter(category=temp).values_list("year").distinct().order_by('year')
+				topics = [str(x[0]) for x in dates if x[0]]	 #[str(x[0]) for x in dates if x[0]]
+				topic = topics[0]
+			context['topic'] = topic
+			if topic == "None":
+				year = None
+			else:
+				year = int(topic)
+			context['items'] = HyperLink.objects.filter(category=temp, year=year)
+			
+		else:			
+			if not topic:
+				topic = Topic.objects.all()[0]
+				topic = topic.name
+			context['topic'] = topic
+			context['items'] = HyperLink.objects.filter(category=temp, topic__name=topic)
+
+		if context['items']:
+			context['randomitem'] = choice(context['items'])
+		
+		
+	elif frame == "top_nav":
+		template = 'frames/top_nav.html'
+		if orderbydate:
+			dates = HyperLink.objects.filter(category=temp).values_list("year").distinct().order_by('year')
+			context['topics'] = [str(x[0]) for x in dates]	#[str(x[0]) for x in dates if x[0]]
 		else:
-			items = HyperLink.objects.filter(category=temp)
-			totitems = items.count()
-			for i in items:
-				if finaldict.get(i.topic.name):
-					finaldict[i.topic.name] += [i]
-				else:
-					finaldict[i.topic.name] = [i]
-			template_items = sorted(finaldict.items())
+			context['topics'] = Topic.objects.all()
 		
-		if items:
-			randomitem = choice(items)
-			
+	elif frame == "content":
+		template = 'frames/content.html'
+		
 
-	else:
-		items = []
 
-	print finaldict
-	context = { 'category' : category, 'items' : template_items, 
-				'randomitem' : randomitem,  'subpath' : SUBPATH, 'totitems' : totitems
-				}
-	return render_to_response('lina/linkslist.html', 
+	return render_to_response(template, 
 								context,
 								context_instance=RequestContext(request))
-
-
-
+