[Hejes-devel] [929] dbblog.py: removed table def for table images, renamed posts. image_url to image_filename; blog/show.html, index.html: image is rendered from static/blog/posts.image_filename
hejes-devel at nytud.hu
hejes-devel at nytud.hu
Wed Sep 11 13:17:08 CEST 2013
Revision: 929
Author: mihaltz
Date: 2013-09-11 13:17:08 +0200 (Wed, 11 Sep 2013)
Log Message:
-----------
dbblog.py: removed table def for table images, renamed posts.image_url to image_filename; blog/show.html, index.html: image is rendered from static/blog/posts.image_filename
Modified Paths:
--------------
trunk/web2py/applications/helyesiras_webdev/controllers/blog.py
trunk/web2py/applications/helyesiras_webdev/databases/blog_posts.table
trunk/web2py/applications/helyesiras_webdev/databases/sql.log
trunk/web2py/applications/helyesiras_webdev/databases/storage.sqlite
trunk/web2py/applications/helyesiras_webdev/models/dbblog.py
trunk/web2py/applications/helyesiras_webdev/models/menu.py
trunk/web2py/applications/helyesiras_webdev/views/blog/index.html
trunk/web2py/applications/helyesiras_webdev/views/blog/show.html
Added Paths:
-----------
trunk/web2py/applications/helyesiras_webdev/static/blog/old_typewriter_100x100.jpg
Modified: trunk/web2py/applications/helyesiras_webdev/controllers/blog.py
===================================================================
--- trunk/web2py/applications/helyesiras_webdev/controllers/blog.py 2013-09-10 14:45:46 UTC (rev 928)
+++ trunk/web2py/applications/helyesiras_webdev/controllers/blog.py 2013-09-11 11:17:08 UTC (rev 929)
@@ -61,12 +61,9 @@
slug = request.args(0)
if slug == None: # no arg: redirect to index
redirect(URL(c='blog', f='index'))
- # query TODO: all tables all data as text
- #rows = dbblog( (dbblog.posts.category==dbblog.categories.id) & (dbblog.posts.slug==slug)).select(
- # left=dbblog.images.on(dbblog.posts.image==dbblog.images.id) )
rows = dbblog( (dbblog.posts.category==dbblog.categories.id) & (dbblog.posts.slug==slug)).select()
if len(rows) == 0: # post not found: redirect to index
- redirect(URL(c='blog', f='index')) # TODO: add message to flash as a var?
+ redirect(URL(c='blog', f='index'))
return dict(categories=cats, tags=tags, post=rows.first())
@@ -99,7 +96,7 @@
def rss():
- """Redirect to feed.rss. For compatibility with feed autodetection."""
+ """Redirect rss.* to feed.rss."""
redirect(URL(c='blog', f='feed', extension='rss'))
Modified: trunk/web2py/applications/helyesiras_webdev/databases/blog_posts.table
===================================================================
--- trunk/web2py/applications/helyesiras_webdev/databases/blog_posts.table 2013-09-10 14:45:46 UTC (rev 928)
+++ trunk/web2py/applications/helyesiras_webdev/databases/blog_posts.table 2013-09-11 11:17:08 UTC (rev 929)
@@ -2,20 +2,20 @@
S'body'
p2
(dp3
-S'length'
+S'sortable'
p4
-I32768
-sS'unique'
+I5
+sS'sql'
p5
-I00
-sS'sortable'
+S'LONGTEXT'
p6
-I5
-sS'sql'
+sS'length'
p7
-S'LONGTEXT'
+I32768
+sS'notnull'
p8
-sS'notnull'
+I00
+sS'unique'
p9
I00
sS'type'
@@ -26,14 +26,14 @@
p12
(dp13
g4
-I255
+I7
sg5
-I00
-sg6
-I7
-sg7
S'INT, INDEX category__idx (category), FOREIGN KEY (category) REFERENCES categories (id) ON DELETE CASCADE'
p14
+sg7
+I255
+sg8
+I00
sg9
I00
sg10
@@ -43,14 +43,14 @@
p16
(dp17
g4
-I255
+I3
sg5
-I00
-sg6
-I3
-sg7
S'VARCHAR(255)'
p18
+sg7
+I255
+sg8
+I00
sg9
I00
sg10
@@ -60,82 +60,90 @@
p20
(dp21
g4
-I255
+I6
sg5
-I00
-sg6
-I6
-sg7
S'LONGTEXT'
p22
+sg7
+I255
+sg8
+I00
sg9
I00
sg10
S'list:string'
p23
-ssS'slug'
+ssS'id'
p24
(dp25
g4
-I255
+I1
sg5
-I01
-sg6
-I2
+S'INT AUTO_INCREMENT NOT NULL'
+p26
sg7
-S'VARCHAR(255) UNIQUE'
-p26
+I255
+sg8
+I00
sg9
I00
sg10
-g19
+S'id'
+p27
ssS'created_on'
-p27
-(dp28
+p28
+(dp29
g4
+I8
+sg5
+S'DATETIME'
+p30
+sg7
I255
-sg5
+sg8
I00
-sg6
-I8
-sg7
-S'DATETIME'
-p29
sg9
I00
sg10
S'datetime'
-p30
-ssS'image_url'
p31
-(dp32
+ssS'slug'
+p32
+(dp33
g4
+I2
+sg5
+S'VARCHAR(255) UNIQUE'
+p34
+sg7
I255
-sg5
+sg8
I00
-sg6
-I4
-sg7
-S'VARCHAR(255)'
-p33
sg9
-I00
+I01
sg10
g19
-ssS'id'
-p34
-(dp35
-g4
+ssS'image_filename'
+p35
+(dp36
+S'length'
+p37
I255
-sg5
+sS'unique'
+p38
I00
-sg6
-I1
-sg7
-S'INT AUTO_INCREMENT NOT NULL'
-p36
-sg9
+sS'sortable'
+p39
+I4
+sS'sql'
+p40
+S'VARCHAR(255)'
+p41
+sS'notnull'
+p42
I00
-sg10
-g34
+sS'type'
+p43
+S'string'
+p44
ss.
\ No newline at end of file
Modified: trunk/web2py/applications/helyesiras_webdev/databases/sql.log
===================================================================
--- trunk/web2py/applications/helyesiras_webdev/databases/sql.log 2013-09-10 14:45:46 UTC (rev 928)
+++ trunk/web2py/applications/helyesiras_webdev/databases/sql.log 2013-09-11 11:17:08 UTC (rev 929)
@@ -102,3 +102,9 @@
success!
TRUNCATE TABLE tags ;
success!
+timestamp: 2013-09-10T18:17:07.574496
+ALTER TABLE posts ADD image_filename VARCHAR(255);
+success!
+timestamp: 2013-09-10T18:17:08.070111
+ALTER TABLE posts DROP COLUMN image_url;
+success!
Modified: trunk/web2py/applications/helyesiras_webdev/databases/storage.sqlite
===================================================================
(Binary files differ)
Modified: trunk/web2py/applications/helyesiras_webdev/models/dbblog.py
===================================================================
--- trunk/web2py/applications/helyesiras_webdev/models/dbblog.py 2013-09-10 14:45:46 UTC (rev 928)
+++ trunk/web2py/applications/helyesiras_webdev/models/dbblog.py 2013-09-11 11:17:08 UTC (rev 929)
@@ -93,12 +93,6 @@
dbblog = DAL("mysql://dbblogadmin:d4bl0GGr@localhost/dbhelyesblog")
# Define the table names and the fields + add restrictions.
-dbblog.define_table('images',
- Field('file', 'upload'),
- Field('title', unique=True),
- migrate='blog_images.table'
- )
-
dbblog.define_table('tags',
Field('name', unique=True),
Field('posts', 'list:reference posts'),
@@ -114,7 +108,7 @@
dbblog.define_table('posts',
Field('slug', unique=True),
Field('title'),
- Field('image_url'),
+ Field('image_filename'),
Field('body', 'text'),
Field('tags', 'list:string'),
Field('category', 'reference categories'),
@@ -124,6 +118,7 @@
dbblog.posts.slug.requires = IS_NOT_EMPTY()
dbblog.posts.title.requires = IS_NOT_EMPTY()
+dbblog.posts.image_filename.requires = IS_NOT_EMPTY()
dbblog.posts.body.requires = IS_NOT_EMPTY()
dbblog.posts.slug.requires = IS_NOT_EMPTY()
dbblog.posts.category.requires = IS_IN_DB(dbblog, dbblog.categories.id, '%(name)s')
Modified: trunk/web2py/applications/helyesiras_webdev/models/menu.py
===================================================================
--- trunk/web2py/applications/helyesiras_webdev/models/menu.py 2013-09-10 14:45:46 UTC (rev 928)
+++ trunk/web2py/applications/helyesiras_webdev/models/menu.py 2013-09-11 11:17:08 UTC (rev 929)
@@ -18,7 +18,7 @@
## your http://google.com/analytics id
response.google_analytics_id = 'UA-40105656-1'
if 'env' in request and request['env'].get('http_host') not in ['helyesiras.hu', 'helyesiras.mta.hu', 'xn--helyesrs-fza2j.mta.hu']:
- print('Running on "{0}", disabling Google Analytics'.format( request['env'].get('http_host')))
+ #print('Running on "{0}", disabling Google Analytics'.format( request['env'].get('http_host')))
response.google_analytics_id = None # disable GA if not running on the production server
#########################################################################
Added: trunk/web2py/applications/helyesiras_webdev/static/blog/old_typewriter_100x100.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/web2py/applications/helyesiras_webdev/static/blog/old_typewriter_100x100.jpg
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/web2py/applications/helyesiras_webdev/views/blog/index.html
===================================================================
--- trunk/web2py/applications/helyesiras_webdev/views/blog/index.html 2013-09-10 14:45:46 UTC (rev 928)
+++ trunk/web2py/applications/helyesiras_webdev/views/blog/index.html 2013-09-11 11:17:08 UTC (rev 929)
@@ -58,7 +58,7 @@
{{for i, row in enumerate(posts):}}
<div class="blog-list{{if i == 0:}} first{{pass}}{{if i == len(posts)-1:}} last{{pass}}">
- <img src="{{=row.posts.image_url}}" width=100 height=100></img>
+ <img src="{{=URL('static', 'blog/' + row.posts.image_filename)}}" width=100 height=100></img>
<div class="blog-lead-inner">
<div class="blog-cat-name"><span>{{=row.categories.name}}</span></div>
<h2>{{=A(row.posts.title, _href=URL(c='blog', f='show', args=[row.posts.slug]))}}</h2>
Modified: trunk/web2py/applications/helyesiras_webdev/views/blog/show.html
===================================================================
--- trunk/web2py/applications/helyesiras_webdev/views/blog/show.html 2013-09-10 14:45:46 UTC (rev 928)
+++ trunk/web2py/applications/helyesiras_webdev/views/blog/show.html 2013-09-11 11:17:08 UTC (rev 929)
@@ -46,7 +46,7 @@
</script>
</div>
<div>
- <img src="{{=post.posts.image_url}}" width=100 height=100 class="blog-index-image" />
+ <img src="{{=URL('static', 'blog/' + post.posts.image_filename)}}" width=100 height=100 class="blog-index-image" />
{{=MARKMIN(post.posts.body)}}
</div>
<div class="clr-l"></div>
More information about the Hejes-devel
mailing list