-
-
Save kimdwkimdw/54d9ca0b741a6cabc37f to your computer and use it in GitHub Desktop.
Revisions
-
kimdwkimdw renamed this gist
Aug 20, 2014 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,4 +4,5 @@ 로 접근 가능하도록.. --> <div class="well" id="article_{{ article.id }}" article_id="{{ article.id }}"> -
kimdwkimdw revised this gist
Aug 20, 2014 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ <!-- DOM을 만들때 항상 article_id 를 넣어준다. $(".well:last").attr("article_id") 로 접근 가능하도록.. --> -
kimdwkimdw revised this gist
Aug 20, 2014 . 1 changed file with 0 additions and 30 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,26 +1,3 @@ function getArticleAfterArticle(article_id) { var EndArticle = false; @@ -67,13 +44,6 @@ $(document).ready(function() { var number = 0; var string; $('#load_more_button').bind('click', function() { var article_id = $(".well:last").attr("article_id"); getArticleAfterArticle(article_id); -
SsonHJ created this gist
Aug 18, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,82 @@ function timeTo(time){ var times = new Date(); var resultString; var millisec; millisec = (new Date(time)).getTime(); times.setTime(millisec); var month = times.getUTCMonth() + 1; if(month < 10){ month = "0"+ month; } var date = times.getUTCDate(); if(date < 10){ date = "0" + date; } resultString = times.getYear()+1900 + "-" + month + "-" + date + " " +times.getUTCHours() + ":" + times.getMinutes() + ":" + times.getSeconds(); return resultString; } function getArticleAfterArticle(article_id) { var EndArticle = false; $.ajax({ url: "/more", dataType: 'JSON', data: { last_article_id : article_id }, success: function(data){ if(data.count == 0){ alert("마지막글입니다"); $("#morebtn").hide(); EndArticle =true; }else{ for (var article_idx in data.article_list) { article = data.article_list[article_idx] string = "<div class='well' id='article_"+ article.id +"'><h1><a href='/article/detail/"+ article.id +"'>" + article.title +"</a></h1><h3>"+ article.author +"</h3><h6>" + timeTo(article.date_created) +"</h6><p> " + article.content +" </p> </div>"; $(string).insertAfter($(".well:last")) } } }, error: function(status){ string = "<div class='well' id='article_"+ data.id +"'><h1>에러가 발생했습니다..</h1></div>"; $("#results").append(string); } }); return true; } $(document).ready(function() { var number = 0; var string; $.ajax({ url: "/rows", dataType: 'JSON', success: function(data){ number = data.rows - 4; } }); $('#load_more_button').bind('click', function() { var article_id = $(".well:last").attr("article_id"); getArticleAfterArticle(article_id); return false; }); }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ @app.route('/', methods=['GET']) def article_list(): context = {} rows = max(Article.query.count() - 5, 5) context['article_list'] = Article.query.order_by( desc(Article.date_created)).limit(rows) return render_template('home.html', context=context, active_tab='timeline') @app.route('/more') def article_more(): last_article_id = request.args.get('last_article_id', 0, type=int) article_list = Article.query.filter(Article.id < last_article_id).order_by( desc(Article.date_created)).limit(5) article_result = [] for article in article_list: article_result.append({'id': article.id, 'title': article.title, 'content': article.content, 'author': article.author, 'category': article.category, 'date_created': article.date_created, }) return jsonify(article_list=article_result, count=article_list.count())