sauliusgrigaitis / swifton Goto Github PK
View Code? Open in Web Editor NEWA Ruby on Rails inspired Web Framework for Swift that runs on Linux and OS X
License: MIT License
A Ruby on Rails inspired Web Framework for Swift that runs on Linux and OS X
License: MIT License
Hello,
I'm learning Swift and I tried compiling this project for fun and I noticed a compiler warning: /home/bob/Swifton/Sources/Spec/ControllerSpec.swift:12:17: warning: variable 'record' was written to, but never read var record:TestModel!
Does holding the result of TestModel.create()
into record
have any purposes ?
Not much more I can add to that in here.
I appreciate your frankness (and I'm sure frustration) of your remark:
IMPORTANT! We don't see any way how to make web development as great as Ruby on Rails or Django with a very static nature of current Swift. We hope that things will change at some point and we will return to active development.
Could you please expound upon this and provide more reasoning as to how (and perhaps maybe why) this is the case? Personally I'm curious about how Swift has this lock-in when compared to Crystal (albeit Crystal is modeled after Ruby and I can see somewhat the difference). I'm just hoping to see things through your eyes better after working on this so diligently as you have and to understand the walls you hit more clearly.
For some reason I got...
root@63612e37d9d8:/Swifton-TodoApp# swift --version
Swift version 3.0-dev (LLVM b361b0fc05, Clang 11493b0f62, Swift fc261045a5)
Target: x86_64-unknown-linux-gnu
root@63612e37d9d8:/Swifton-TodoApp# ls
Dockerfile MIT-LICENSE Package.swift Packages Procfile Public README.md Sources Views app.json
root@63612e37d9d8:/Swifton-TodoApp# swift build
Compiling Swift Module 'TemplateLoadertest' (2 sources)
Compiling Swift Module 'Nodestest' (4 sources)
/Swifton-TodoApp/Packages/Stencil-0.5.2/Tests/TemplateLoader/InheritenceSpec.swift:8:21: warning: __FILE__ is deprecated and will be removed in Swift 3, please use #file
let path = Path(__FILE__) + ".." + ".." + "fixtures"
^~~~~~~~
#file
/Swifton-TodoApp/Packages/Stencil-0.5.2/Tests/TemplateLoader/InheritenceSpec.swift:1:8: error: no such module 'Spectre'
import Spectre
^
/Swifton-TodoApp/Packages/Stencil-0.5.2/Tests/TemplateLoader/InheritenceSpec.swift:8:21: warning: __FILE__ is deprecated and will be removed in Swift 3, please use #file
let path = Path(__FILE__) + ".." + ".." + "fixtures"
^~~~~~~~
#file
/Swifton-TodoApp/Packages/Stencil-0.5.2/Tests/TemplateLoader/InheritenceSpec.swift:1:8: error: no such module 'Spectre'
import Spectre
^
/Swifton-TodoApp/Packages/Stencil-0.5.2/Tests/Nodes/NodeSpec.swift:1:8: error: no such module 'Spectre'
import Spectre
^
/Swifton-TodoApp/Packages/Stencil-0.5.2/Tests/Nodes/NodeSpec.swift:1:8: error: no such module 'Spectre'
import Spectre
^
/Swifton-TodoApp/Packages/Stencil-0.5.2/Tests/Nodes/NodeSpec.swift:1:8: error: no such module 'Spectre'
import Spectre
^
/Swifton-TodoApp/Packages/Stencil-0.5.2/Tests/Nodes/NodeSpec.swift:1:8: error: no such module 'Spectre'
import Spectre
^
<unknown>:0: error: build had 2 command failures
error: exit(1): /usr/bin/swift-build-tool -f /Swifton-TodoApp/.build/debug.yaml default
Any hint? Thanks
Is it normal that we are importing Foundation in MimeType.swift? This should be a platform agnostic framework and I'm not even sure why we need Foundation in that source file.
Using the last version of Swift (Swift version 3.0-dev)
When executing: swift build
Cloning https://github.com/necolt/Stencil.git
HEAD is now at ee7c76f Merge pull request #3 from weby/master
Resolved version: 0.5.6
Cloning https://github.com/necolt/PathKit.git
HEAD is now at c99537a Merge pull request #2 from weby/master
Resolved version: 0.6.4
Empty manifest file is not supported anymore. Use `swift package init` to autogenerate.
error: The package at `/bitnami/swift/Swifton/Packages/PathKit.git' has no Package.swift for the specific version: 0.6.4
It seems that the version of the dependencies are correct.
Application Controller allows to define filters that are accessible in child controllers, also it's possible to overwrite those filters in child controllers.
I was thinking if it's possible to map routes directly to methods of Controller. For example:
router.get("/", TodosController().index)
etc
Resources can be implemented by adopting protocols. I.e. TodosController adopts Resource protocol and implements some or all of the protocol's methods. router.resources() will expect a class which adopts that protocol.
Filtering can be implemented by looking up method names via reflection.
What do you think of this approach?
We need to extract Parameters parsing from Router to Middleware.
I started to add Cookies code here, but actually it should be extracted to Middleware.
TodoApp is good starting point, but would be really great to build fully featured app that developers could use as a reference. Please suggest ideas and discuss about it here. Few initial ideas:
Seem's like there's no suck dictionary or files, bug:
vagrant@vagrant-ubuntu-wily-64:~/test_proj1/Packages/PathKit-0.6.1/Tests$ ll total 36 drwxrwxr-x 3 vagrant vagrant 4096 Mar 14 13:36 ./ drwxrwxr-x 8 vagrant vagrant 4096 Mar 14 13:36 ../ drwxrwxr-x 5 vagrant vagrant 4096 Mar 14 13:36 Fixtures/ -rw-rw-r-- 1 vagrant vagrant 733 Mar 14 13:36 Info.plist -rw-rw-r-- 1 vagrant vagrant 2293 Mar 14 13:36 ManipulationTests.swift -rw-rw-r-- 1 vagrant vagrant 12605 Mar 14 13:36 PathKitTests.swift vagrant@vagrant-ubuntu-wily-64:~/test_proj1/Packages/PathKit-0.6.1/Tests$ vagrant@vagrant-ubuntu-wily-64:~/test_proj1/Packages/PathKit-0.6.1/Tests$ vagrant@vagrant-ubuntu-wily-64:~/test_proj1/Packages/PathKit-0.6.1/Tests$ vagrant@vagrant-ubuntu-wily-64:~/test_proj1/Packages/PathKit-0.6.1/Tests$ cd Fixtures/ vagrant@vagrant-ubuntu-wily-64:~/test_proj1/Packages/PathKit-0.6.1/Tests/Fixtures$ ll total 20 drwxrwxr-x 5 vagrant vagrant 4096 Mar 14 13:36 ./ drwxrwxr-x 3 vagrant vagrant 4096 Mar 14 13:36 ../ drwxrwxr-x 3 vagrant vagrant 4096 Mar 14 13:36 directory/ -rw-rw-r-- 1 vagrant vagrant 0 Mar 14 13:36 file drwxrwxr-x 2 vagrant vagrant 4096 Mar 14 13:36 permissions/ drwxrwxr-x 2 vagrant vagrant 4096 Mar 14 13:36 symlinks/ vagrant@vagrant-ubuntu-wily-64:~/test_proj1/Packages/PathKit-0.6.1/Tests/Fixtures$
Recent Swift snapshots introduced breaking changes. First we need to get Swifton's dependencies ported.
Currently Quick tests has few big issues:
Since we have small set of "integration" tests - it will be easy to rewrite it.
TodoApp deploys on Heroku, but for some reason templates are not found. It could be working directory path issue, so probably quickest solution would be to play with SwiftonConfig.viewsDirectory
variable.
We should embrace https://github.com/open-swift/S4 initiative. Porting to S4 shouldn't be very complex, because we already use Inquiline abstractions. Also this port should be tested against S4 supporting server ( https://github.com/VeniceX/HTTPServer ? ).
Would you reconsider using this photo to represent this project? Is this the message you want to send to someone who sees this project page for the first time?
EDIT: Not to mention that it's probably a copyright infringement.
I'm trying to load images from the public directory but it seems from looking at the router code that anything loaded from the public directory needs to be source code—like css or js files.
// In Router.swift
if let body = String(data:contents!, encoding: NSUTF8StringEncoding) {
return Response(.Ok, contentType: "text/plain; charset=utf8", body: body)
}
We should be able to also load images and other assets from that directory. Also CSS files and JS files should return a different mimetype than text/plain
.
Now that Swifton defines its own ContentTypes
in Response.swift
we need to add the missing mime-types in order to return the correct content-type.
Returning a text/plain
type causes errors on certain browsers that will only parse a file if it has the expected mime-type:
Did not parse stylesheet at 'http://localhost:8080/css/style.css' because non CSS MIME types are not allowed in strict mode.
Here's what needed:
MimeType.swift
ContentType
enum in Response.swift
Router.swift:38
Somewhere in the chain encoding is messed up - if I enter issue name "ąęčįčęėįčęėįčęš" in TodoApp I actually get "Ä�Ä�Ä�įÄ�Ä�Ä�įÄ�Ä�Ä�įÄ�Ä�Å¡ "
Hi, sorry for being upfront but it seems last commit was more than half a year ago.
Any road map or plans ?
Hi guys,
I see you are using some code I wrote for my project - https://github.com/glock45/swifter/blob/master/Sources/String%2BMisc.swift
Swifton: https://github.com/necolt/Swifton/blob/master/Sources/Extensions.swift
Can you please add my license to Extensions.swift file ?
Best and good luck with the project,
DK
This is kind of the same as #25 but that issue encompassed two issues:
// Router.swift:111
...
if let body = String(data:contents!, encoding: NSUTF8StringEncoding) {
...
Any file that is a jpeg or png etc... Returns a nil body on this line which leads to this code returning a notFound
Response:
// Router.swift:95
if let staticFile = serveStaticFile(newRequest) {
return staticFile as! Response
}
return notFound(newRequest) as! Response
So we are still having an issue with not returning media assets this isn't in line with the README
Static assets (JavaScript, CSS, images etc.) are loaded from Public directory by default
This is crucial and needs to be fixed before Swifton can be useful. I can't imagine a website without any media assets!
I'm willing to investigate this much further but we may need to modify the router to return ResponseType
s from the router instead of Inquiline Response
types... Of course any other thoughts are welcome!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.