Skip to content

Commit

Permalink
Merge pull request #3 in PROSA/prosa from bugfix/PROSA-13-al-agregar-…
Browse files Browse the repository at this point in the history
…una-imagen-y-presionar to master

# By Eduardo  Díaz Cortés
# Via Eduardo  Díaz Cortés
* commit 'c2e185cfa2acea44fe81817bec6ad35866c0fde0':
  PROSA-13 Fix bug.
  • Loading branch information
lnds committed Mar 30, 2015
2 parents ba1abc8 + c2e185c commit a88e2cd
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 5 deletions.
13 changes: 13 additions & 0 deletions app/controllers/ImagesController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import play.api.data.Form
import play.api.data.Forms._
import play.api.mvc.Controller
import tools.ContentManager
import play.api.libs.json._


object ImagesController extends Controller with DBElement with AuthElement with AuthConfigImpl {
Expand Down Expand Up @@ -37,6 +38,18 @@ object ImagesController extends Controller with DBElement with AuthElement with
)
}

case class ImageFile(url:String)

def editorUpload = StackAction(parse.multipartFormData, AuthorityKey -> Writer) { implicit request =>
val tempFile = File.createTempFile("image_", ".img")
val image = request.body.files.head
image.ref.moveTo(tempFile, replace=true)
val img = Images.addImage(tempFile.getAbsolutePath, image.contentType.getOrElse(""))
val url = ContentManager.putFile(img.id, tempFile, img.contentType)
Images.update(img.copy(url = Some(url)))
Ok(Json.obj("files" -> Json.arr(Json.obj("url" -> url))))
}


}

Expand Down
2 changes: 1 addition & 1 deletion app/views/main_editor.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
$('.editor').mediumInsert({
editor: editor,
addons: {
images: {imagesUploadScript:"@routes.ImagesController.upload"},
images: {uploadScript:"@routes.ImagesController.editorUpload"},
embeds: {}
}
})
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := """prosa-blog-server"""

version := "0.2.12.2"
version := "0.2.13.3"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

Expand Down
2 changes: 1 addition & 1 deletion conf/messages
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ posts.success.imported=Artículo Importados
#footer

footer.copyright=© 2014 Eduardo Díaz. Todos los derechos reservados.
footer.prosa=Publicado usando Prosa - release 0.2.12.2
footer.prosa=Publicado usando Prosa - release 0.2.13.3
footer.image.copyright=Imagen de portada (CC) Indi Samarajiva

placeholders.editor.type_here=Escriba su texto
Expand Down
2 changes: 1 addition & 1 deletion conf/messages.en
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ posts.success.imported=Artículo Importados
#footer

footer.copyright=© 2014 Eduardo Díaz. All rights reserved.
footer.prosa=Publish using Prosa - release 0.2.11.1
footer.prosa=Publish using Prosa - release 0.2.13.3
footer.image.copyright=Cover imagen (CC) Indi Samarajiva

placeholders.editor.type_here=Write your text
2 changes: 1 addition & 1 deletion conf/messages.es
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ posts.success.imported=Artículo Importados
#footer

footer.copyright=© 2014 Eduardo Díaz. Todos los derechos reservados.
footer.prosa=Publicado usando Prosa - release 0.2.12.2
footer.prosa=Publicado usando Prosa - release 0.2.13.3
footer.image.copyright=Imagen de portada (CC) Indi Samarajiva

placeholders.editor.type_here=Escriba su texto
Expand Down
1 change: 1 addition & 0 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ GET /blogs/edit/:id controllers.BlogsControl
POST /blogs/edit/:id controllers.BlogsController.update(id:String)

POST /images/uploadImage controllers.ImagesController.upload()
POST /images/editorUploadImage controllers.ImagesController.editorUpload()
GET /images/get/:id controllers.ContentController.getImage(id)

GET /blog/:alias controllers.PostsGuestController.index(alias:String, pageNum:Int ?=0)
Expand Down

0 comments on commit a88e2cd

Please sign in to comment.