Web Site


Website maintained by ntrifunovic Theme by mattgraham modified by ntrifunovic

Ovaj tekst je namenjen kao pomoc onima koji zele da naprave sajt slican ovom sajtu. Ako imate pitanja slobodno ih postavite u komentarima na dnu strane.

Koriscene tehnologije

Ovaj web site je napravljen koristeci Python kao i pakete flask, FlatPages, Frozen-Flask i markdown.

Kao web-framework za razvoj sajta koriscen je Flask.

Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions. And before you ask: It's BSD licensed!

Ceo sajt se dinamicki generise iz fajlova koji su u markdown formatu koristeci pakete markdown i FlatPages. Paket markdown generise html od markdown fajlova kojima se pristupa pomocu paketa FlatPages.

Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).

Flask-FlatPages provides a collections of pages to your Flask application. Pages are built from “flat” text files as opposed to a relational database.

Vise o koriscenim paketima mozete pronaci na:

Pakete mozete instalirati koristeci pip.

pip install markdown
pip install flask
pip install Frozen-Flask
pip install Flask-FlatPages

Vise o pip-u mozete pronaci na https://pypi.python.org/pypi/pip.

Nakon sto nabavite sve potrebne pakete mozete pokusati da napravite svoj sajt pomocu izvornog koda i template-a datih u nastavku teksta.


Preporucujem da se za rad na projektima u python-u za svaki projekat koji zavisi od nekih paketa kreira virtuelno okruzenje koristeci virtualenv.

virtualenv is a tool to create isolated Python environments.

virtualenv mozete instalirati sledecom komandom:

pip install virtualenv

Virtuelno okruzenje se pravi komandom:

virtualenv IME_OKRUZENJA

Pre koriscenja virtuelnog okruzenja ono se mora aktivirati komandom:

source IME_OKRUZENJA/bin/activate

Vise o virtualenv-u mozete pronaci na: http://virtualenv.org

Kada instalirate i aktivirate virtualenv sve potrebne pakete mozete instalirati iz fajla requirements.txt komandom:

pip install -r requirements.txt

Sadrzaj fajla requirements.txt:



Koriscena tema je modifikovana verzija teme Midnight by mattgraham.

Source code

# file:   site.py
# author: ntrifunovic

import os
import sys

from flask import Flask, request, url_for, render_template
from flask_flatpages import FlatPages, pygments_style_defs
from flask_frozen import Freezer

import markdown
import mdx_mathjax

if not 'HEROKU' in os.environ:
    DEBUG = True


def my_markdown(text):
    import pygments

    extensions = ['mathjax', 'codehilite', 'toc', 'abbr']
    return markdown.markdown(text, extensions)


app = Flask(__name__)
pages = FlatPages(app)
freezer = Freezer(app, with_static_files = False)

def index():
    spages = sorted(pages, 
                    key = lambda page: (page['topic'] if 'topic' in page.meta else None,
                                        page['order'] if 'order' in page.meta else None,
    return render_template('index.html', pages = spages)

def pygments_css():
    return pygments_style_defs('native'), 200, {'Content-Type': 'text/css'}

def page(path):
    spages = sorted(pages, 
                    key = lambda page: (page['topic'] if 'topic' in page.meta else None,
                                        page['order'] if 'order' in page.meta else None,
    return render_template('doc.html', output = pages.get_or_404(path), pages = spages)

if __name__ == "__main__":
    if len(sys.argv) > 1 and sys.argv[1] == "build":
        port = int(os.environ.get('PORT', 5000))
        app.run(host='', port=port)


Flask kao podrazumevani templating sistem koristi Jinja template engine. Sve templejte treba staviti u folder templates koji treba napraviti u istom folderu u kome se nalazi source code.

Jinja2 is a full featured template engine for Python. It has full unicode support, an optional integrated sandboxed execution environment, widely used and BSD licensed.

Vise informacija mozete pronaci na: http://jinja.pocoo.org


  title:  base.html
  author: ntrifunovic

{% macro full_title(page) -%}
  {% if page.topic %}
    {{ page.topic }} \
  {% endif %}


  {% if page.order %}
    {{ page.order }} .
  {% endif %}


  {{ page.title }}
  {{ caller() }}
{%- endmacro %}

{% macro pritty_title(page) -%}
  <h1>{{ page.title }}</h1>
  {% if page.topic %}
       -{{ page.topic }}-
  {% endif %}
  {{ caller() }}
{%- endmacro %}

<!doctype html>
   <meta charset="UTF-8">
   <meta http-equiv="X-UA-Compatible" content="chrome=1">
   <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

   <title>{% block up_title %}ntrifunovic{% endblock %}</title>
   <link rel="stylesheet" href="{{ url_for('pygments_css') }}">
   <link rel="stylesheet" href="{{ url_for('static', filename='stylesheets/styles.css') }}">
   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
     var _gaq = _gaq || [];
     _gaq.push(['_setAccount', 'UA-38492106-1']);

     (function() {
     var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
     ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
   {% block extra_scripts %}
   {% endblock extra_scripts %}
      <div id="header">
          <li class="fork"><a href="{{ url_for('index') }}">Home</a></li>
      </div><!-- end header -->

      <div id="index">
        {% block nav %}
          {% for page in pages %}
            <a href="{{ url_for("page", path=page.path) }}" class="index-item">{% call full_title(page) %}{% endcall %}</a>
          {% else %}
          <li>No stuff.</li>
          {% endfor %}
        {% endblock nav %}

    <div class="wrapper">
        <div id="title">
          {% block title %}{% endblock %}
          <span class="credits left">
            Project maintained by <a href="https://github.com/ntrifunovic">ntrifunovic</a>
          <span class="credits right">Theme by <a href="http://twitter.com/#!/michigangraham">mattgraham</a> <b>modified</b> by <a href="https://github.com/ntrifunovic">ntrifunovic</a></span>

        {% block content %}
          {{ output|safe }}
        {% endblock content %}


    <div id="footer-bar">
      <div id="footer-bar-content">
        <hr class="spaceless">

        <span id = "social">

        <hr class="spaceless">

        {# FB LIKE #}
        <span id="fb-like-b">
          <div class="fb-like" data-send="true" data-layout="button_count" data-width="50" data-show-faces="true"></div>
              <div id="fb-root"></div>
              <script>(function(d, s, id) {
                var js, fjs = d.getElementsByTagName(s)[0];
                if (d.getElementById(id)) return;
                js = d.createElement(s); js.id = id;
                js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
                fjs.parentNode.insertBefore(js, fjs);
                }(document, 'script', 'facebook-jssdk'));

        <hr class="spaceless">

        {# TWEET #}
        <span id="tweetb-b">
          <a href="https://twitter.com/share" class="twitter-share-button" data-size="medium">Tweet</a>
          <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

        <hr class="spaceless">

        {# GOOGLE +1 #}
        <span id="google-pb">
          <!-- Place this tag where you want the +1 button to render. -->
          <div class="g-plusone" data-size="medium"></div>

          <!-- Place this tag after the last +1 button tag. -->
            (function() {
            var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
            po.src = 'https://apis.google.com/js/plusone.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);

        <hr class="spaceless">



  title: index.html
  author: ntrifunovic

{% extends "base.html" %}

{% block content %}
<section id="naslovna">
  <div id="title">
  <hr class = "spaceless">
  <a href="http://rs.linkedin.com/in/ntrifunovic/">
    <img src="{{ url_for('static', filename='images/ja_2.jpg') }}" class = "spaceless">
  <hr class = "spaceless">

{% endblock %}


  title:  doc.html
  author: ntrifunovic

{% extends "base.html" %}

{% block extra_scripts %}
<script type="text/x-mathjax-config">
    tex2jax: {
      inlineMath: [ ['$','$'] ],
      displayMath: [ ['$$','$$'] ],
      processEscapes: true
{% endblock %}

{% block title%}
{% call pritty_title(output) %}{% endcall %}
{% endblock %}

{% block up_title %}
{% call full_title(output) %}{% endcall %}
{% endblock %}

{% block content %}
   {{ super() }}
   {# DISQUS #}
    <div id="disqus_thread"></div>
    <script type="text/javascript">
        var disqus_shortname = 'ntrifunovic'; // required: replace example with your forum shortname
    var disqus_title = '{{ output.topic }}\\{{ output.title }}';
    var disqus_identifier = '{{ output.topic }}\\{{ output.title }}';

        /* * * DON'T EDIT BELOW THIS LINE * * */
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>

{% endblock content %}

Prmer stranice u Markdown formatu

topic: Uvod u C++
order: 7
title: Pokazivaci

**(eng. Pointers)**

* Promenjiva tipa pokazivac na neki tip se deklarise na sledeci nacin

        tip *imePokazivaca;

* Vrednost pokazivaca predstavlja adresu u memoriji na kojoj se nalazi promenjiva onog tipa koji je koriscen pri deklaraciji pokazivaca
* Memoriskoj lokaciji na koju ukazuje pokazivac pristupamo unarnim prefiksnim operatorom `*`
* Unarni prefiksni operator `&` vraca adresu podatka u memoriji
* Za pristup elementima strukture preko pokazivaca koristi se operator `->`
* Pokazivaci se ponasaju kao i drugi podaci
    * Mogu se praviti nizovi pokazivaca
    * Strukture u sebi mogu sadrzati pokazivace


    int x = 10;
    int *px = &x, y; // y nije pokazivac
    *px = 3;
    y = x;

*Koja je vrednost u promenjivoj y ?*
> Resenje: 3

    // Pristupanje elementima strukture preko pointera
    Tacka *pt = &t;
    (*pt).x = 0;
    pt->y = 0;

Sve stranice su dostupne i u markdown formatu na adresi: https://github.com/ntrifunovic/ntrifunovic-pages. Ako mislite da mozete da unapredite neku od stranica na ovom sajtu mozete uraditi Fork & Pull ovog repositorija kao sto je objasnjeno na ovoj stranici.

Free Hosting

Ovaj website koristi free hosting i dostupan ja na dve adrese http://ntrifunovic.github.com i http://ntrifunovic.herokuapp.com.

Vise o free hosting-u koji ovaj website koristi mozete pronaci na:

comments powered by Disqus