Skip to content

fossix/fossix_site

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reference for Developers/Maintainers

Requirements/Installations

Needed Flask Extensions

  • Login
  • SQLAlchemy
  • OpenID
  • Markdown
  • Script
  • Cache
  • Classy
  • WTF

Needed Python modules

  • Psycopg2
  • Pygments
  • Smartypants
  • Python-memcached
  • Alembic

Content Editing/Creating

Supported Markdown in Fossix

The current markdown is based on python markdown with many extensions. For a detailed look at the python markdown documentation (http://pythonhosted.org/Markdown)

Extensions enabled

  • extra
  • sane_lists
  • codehilite
  • smartypants

Fossix Design

Site design

The site design is mainly targeted to the readers. Some research has been made for the legibility of the content. Based on some readings the following are done:

  • The font size is set at 16px to make the content more legible.
  • discontinued usage of justification, seems it is a bad idea to use it.

User authentication

Roles

  • Administrator
  • Moderator
  • Author
  • Member

Workflow

  • Author writes a Content [Draft] and submits for review [Review]
  • Mails sent to all reviewers (based on the tags)
  • Reviewer approves and article gets published [Published]

User Information

User will need to provide subject matter expertise in his/her profile

If there are no information provided then based on their comments, the reading style etc score will be generated for each topic/tag.

Reviewer Vs Moderator Vs Administrator

Every author will be a reviewer based on the subject matter expertise they have provided or that has been calculated. Moderators are appointed or auto upgraded based on the karma they have earned. There are no special badges like Stackoverflow, and no role identification in their miniprofile, but a star in their profile page will indicate that they are either moderators or administrators, and their email addresses will be visible to all members of the site, and cannot restrict messages from any user.

Content Types

Types

Article

More than 500 words of content will automatically get categorized as Article

News/Commentary

Short content targeted to supplement/comment an article. Any member can create a new/commentary.

Comments

Comments can be added for any content. Meaning comments can be added for a comment itself. That will effectively show up as threads.

Database Design

The database is designed to have versions of every content in the site. Articles, comments, news, review comments, all have history of edits. The only exception to this is user specific data, like the user’s profile itself and the messages that a user has recieved. This means, when a message has been deleted there is not way to recover it. But, again, technically speaking, the message will not be deleted until both the parties involved “removes” the message from their “view”.

Database

Design

The database used in fossix is postgresql.

The database is designed to review comments, all have history of edits. The only exception to this is have versions of every content in the site. Articles, comments, news, user specific data, like the user’s profile itself and the messages that a user has recieved. This means, when a message has been deleted there is not way to recover it. But, again, technically speaking, the message will not be deleted until both the parties involved “removes” the message from their “view”.

Basic Commands

Listing all tables in the database
select table_name from information_schema.tables where table_schema='public';
Date defaults

Date default setting could not be made through sql alchemy. The utcnow breaks migration, and sqlalchemy itself doesn’t seem to understand the NOW()/now() string as default in the database side. So we have to manually update if are going to create the tables anytime again.

alter table content_base alter column create_date set default now();
alter table content_versions alter column last_changed set default now();

The database models

Content History -> a table which stores history Content -> represents Articles, Comment and News User -> represents users and user profiles on the system Message -> stores messages sent and recieved between users OpenID -> Each user can attach multiple openID’s to his account Keywords -> Tags representing the content, can refer any Content

Tables

Content History Table
ColumnTypeModifiers
idintegernot null, auto increment, pk
version_numintegernot null, index
content_idintegernot null, refers Content table
contenttextnot null
tagsintegernot null, refers Keywords table
titlevarcharnot null, unique, index
last_changeddatenot null
changed byintegernot null, refers User table
stateintegernot null, [saved, approved, rejected, pending…]

The table will have a unique constraint on both version_num and content_id, because it makes sense that there cannot be versions with two different version numbes for the same content.

Content Table (Things that don’t require versioning)
ColumnTypeModifiers
idintegernot null, auto increment, pk
current_versionintegerrefers history version_num
create_datedatenot null, default: Today
created_byintegerreferences User table
like_countintegerdefault: 0
read_countintegerdefault: 0
comment_countintegerdefault: 0
typeintegernot null, [article, news, comment]
refers_tointegerrefers to Content Table
Message
ColumnTypeModifiers
idintegernot null, auto increment, pk
fromintegerrefers to User table
tointegetrefers to User table
messagevarchar(300)Not null
User
ColumnTypeModifiers
idintegernot null, auto increment, pk
usernamevarchar(32)not null, unique
fullnamevarchar(64)
emailvarchar(150)not null, unique
date_joineddatenot null
roleintegerdefault: user, [user, author, moderator, admin]
karmaintegerdefault: 0
email_miscbooleandefault: false
email_alertbooleandefault: false
statusintegerdefault: active, [active, blocked]
OpenID
ColumnTypeModifiers
idintegernot null, auto increment, pk
urlvarchar(256)not null
user_idintegernot null, refers User table
Keywords
ColumnTypeModifiers
idintergernot null, auto increment, pk
keywordvarchar(25)not null, unique
ContentTags
ColumnTypeModifiers
content_idintegerrefers Content Table
keyword_idintegerrefers Keyword Table

Views

Content

A content view from both content history table and content table.

Column
content_id
version_num
content
tags
last_changed
changed_by
state
create_date
created_by
like_count
read_count
comment_count
type
refers_to

This view is created manually in the postgresql database. SQLalchemy doesn’t have native support to create views, but can be done as answered in stackoverflow.

CREATE OR REPLACE VIEW content AS 
    SELECT a.content_id AS id, a.title, a.last_changed, a.changed_by, 
    a.state, a.version_num, b.read_count, b.like_count, b.comment_count, 
    b.refers_to from content_versions a, content_base b 
    where content_id=id and (a.content_id,a.version_num) in 
    (select content_id, max(version_num) from content_versions group by
    content_id);

Misc info

Working with database

Postgres shell

To open the database in shell, login as the postgres user and type psql fossixdb List all the tables - \dt View the structure of the table - \d TABLENAME

Database migration using Alembic

alembic revision -m “Some message regarding the upgrade” Edit the version scripts if needed and then alembic upgrade|downgrade version|head

URL Tree

Public

  • /article The last published article will be displayed
  • /article/<id>/[<title>]
  • /article/edit/<id> (Login required - author/moderator)
  • /article/create (login required)
  • /account/login
  • /account/create
  • /account/profile (login required)
  • /account/edit[profile] (login required)
  • /user/<username>
  • /user/following
  • /user/followers
  • /moderate/comments (login required - moderator)
  • /moderate/posts (login required - moderator)
  • /moderate/users
  • /about
  • /about/<id>/<title>
  • /sitemap [,.xml]
  • /feed.[rss, json, xml]
  • /api(?)

Ajax

Misc Info

References/Documents

Implementation references

Features that might be used in fossix

Documentations/Snippets/QA

About

Old flask based fossix website code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published