8000 GitHub - noteflakes/syntropy: A Web Framework for Ruby
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

noteflakes/syntropy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Syntropy

A Web Framework for Ruby

Ruby gem Tests MIT License

What is Syntropy?

| Syntropy: A tendency towards complexity, structure, order, organization of ever more advantageous and orderly patterns.

Syntropy is a WIP web framework for building multi-page and single-page apps. Syntropy uses file tree-based routing, and provides controllers for a number of common patterns, such as a SPA with client-side rendering, a standard server-rendered MPA, a REST API etc.

Routing

Routing is performed automatically by following the tree structure of the Syntropy app. A simple example:

site/
├ _layout/
| └ default.rb
├ _articles/
| └ 2025-06-01-hello_world.md
├ api/
| └ v1.rb
├ assets/
| ├ css/
| ├ img/
| └ js/
├ about.md
├ archive.rb
├ index.rb
└ robots.txt

The routing follows the file hierarchy, and Syntropy knows how to serve static asset files (CSS, JS, images...) as well as render markdown files and run custom Ruby code.

What does a Syntropic Ruby module look like?

Consider archive.rb in the example above. We want to get a list of articles and render it with the given layout:

# archive.rb
@@layout = import('$layout/default')

def articles
  Syntropy.stamped_file_entries('/_articles')
end

@@layout.apply(title: 'archive') {
  div {
    ul {
      articles.each { |article|
        li { a(article.title, href: article.url) }
      }
    }
  }
}

But a module can be something completely different:

# api/v1.rb
class APIV1 < Syntropy::RPCAPI
  def initialize(db)
    @db = db
  end

  # /posts
  def all(req)
    @db[:posts].order_by(:stamp.desc).to_a
  end

  def by_id(req)
    id = req.validate_param(:id, /^{4,32}$/)
    @db[:posts].where(id: id).first
  end
end

APIV1.new(Syntropy.env.open_db)

Basically, the return value of the module is a template or a resource that responds to the request.

About

A Web Framework for Ruby

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0